Added and improved comments for javascript code.