more refactoring and cleanup