More of the javascript refactor