Made a bit more modular

Also now loads javascript at end rather than head