Rearrange the JavaScript to use modules in order to be more maintainable. I still need to look at how the module is initialized to see if that's the right way, and also I want to break down some of the modules further.
Moved init to the top of the module, since it looks better that way.