Cleanup and refactoring.