Remove unused variable
Remove unused functions and parameters
Move initialisation code to functions
Remove redundant line

localStorage triggers this on page load anyway
Reorder statements for easier reading
Move mobile device detection to a function

avoids code duplication
Merge pull request #188 from lorenzhs/cleanup

Code cleanup