Fixes for compiling with mingw