Refactor and separate js files.