more refactoring / cleanup