more UI code and some refactoring