Refactor code so that there are smaller js files.