Implement history with undo/redo.