minor refactorings
bugfixes