Cleanup and refactorings.