I'm -1 on mixing commits.

You have code refactors (such as here) and bug fixes elsewhere, and platform portability elsewhere.
Please split each of these into distinct commits.

It's very very very hard to review a change when it's doing lots of unrelated things together.