first attempt at cleaning up the javascript client