Fix some more mingw compatibility issues reported by Jeremy Hedges.

We still have the issue of SEH use that needs to be resolved