fix headers for MINGW
many win32 compatibility fixes