Comments and fixes to main.js