some refactoring and some changes to the ui