Moved platform-specific code into helper functions