smaller fixes and refactorings