More changes to better support compilation on Windows

Tested with MinGW/MSVC for 32 and 64bit.