Cleaning up main.js, adding a few comments