small bugfixes and refactorings added