Update to Main.js

Reformatted the main.js layout to be more readable and sensible.