Clean up the javascript client code a bit more