Cleaned up the JS a bit