Added __APPLE__ preprocessor checks in an attempt to build for apple. Untested.