misc refactoring