Major cleanup. Remove unused code and files
Add a bunch of JavaScript events.