minor cleanup + refactoring