bugfixes after refactoring