Changed APPLE stuff to #ifdef __APPLE__ stuff