Added notes to main.js to better understand what the code is doing.