Cleanup.
Fix bug where history was wiped out.