clean up and refactoring.