Making ui.js structure clearer