Mac OS X Compatibility

Initial work to make it build