minor cleanup and js refactor