Major refactoring and removal of unused classes. Moved many config values into preferences