More refactoring, plus minor ui changes