Various Mac OS X tweaks to get this to build. Probably breaking things.