Refactoring the js to kill main.js. Yay!