added settings dialog, some small refactoring