Hoisted all JS vars and added comments