cleanup and refactoring.