Cleaning up some JavaScript bits