Fix a few bugs in the javascripts