Small refactoring of client side javascript.