Removed lots of messy JS, using some new hooks and generally cleaned up