Refactor and cleanup.
Refactoring.