Implement undo with deepcopy