Tidy up some javascript