Fixed several issues when compiling with gcc.