Bugfixes due to refactoring