Bug fixes for compiling with mingw32.