Clean up and document main.js