Continued refactoring of javascript.