Moved UI code to ui.js