Moved all javascript on html templates to the end of the respective files to make page loading quicker, also reformatted some of the files for proper indentation and likewise stuff.