mingw build fixes (tested with i686-w64-mingw32 on linux-x86_64)