Major refactor

Changed global variables to closures commented a few files and got
minifaction to work. Restructured as the project is starting to get
larger.