Cleanup and refactor.