Started refactoring the JS files.