Code Formatting Changes

- Moved some functions around within the file
- Added an additional check at the end to see if device supports
orientationevents