Further refactoring
Bugfixing