more PR feedback (mostly minor refactoring)