refactoring and clean-up, part 1