Refactoring and Bugfixing