Mingw fixes

Some fixes that enabled me to compile on MinGW.