Fix OS X build.

Few fixes to OS X, still needs a bit of work though.