Refactoring of javascript.