Refactored so most (if not all) of the OSX code is isolated