More refactoring and UI improvements.