continued clean up and refactoring