Refactored global variables into global namespace and added template.js for templates.
Fixed spacing issues with sublime.