Clean up the JS a bit

This piece of crap really needs a rewrite from scratch...
Don't send emails for now