Added APPLE define to allow compilation on OS X