small fixes and refactorings