refactoring and GUI improvements