add comments in main javascript file, clean up some code