ui.js refactoring.