bugfixes to previous refactorings