Fixed JS being run everywhere. Fixed authentication. Restructured JS to be modular.
Fixed merge conflict.