slight refactorings and cleanup