Refactored Javascript so that modules are seperate files.