minor refactoring and some preparation for incoming changes