Shuffle more of the javascript into the actual javascript
Start reorganising code for enhanced sanity