First pass at cleaning up the js