several minor refactorings