some minor refactoring in preparation for new features