Cleaning up some JavaScript