some refactoring and a GUI