Update main.js

Clean up code, add notes, take out things that I don't understand (/hopefully don't need)