Moved fn from master.js to inline because GCC kept removing it, removed a bit of dead code, cleaned up user agent testing for iOS standalone app, and converted two for-loops to while. Also converted all spaces to tabs