Fix for undo and redo