many minor refactorings