Improvements to `ui.js`