Refactored and added comments

Refactored a lot of methods. Moved all the Javascript to a JS file. Added comments to the Helper.