some fixes and _slight_ refactorings