More fixes and workarounds for MinGW