Improvements to ui.py