Various build fixes for mingw32 target.