Finish refactor into separate js files