refactored a bunch. separated GUI code from other common logic, to make way for a separate settings dialog (#29)