Added handlers for undo and redo.