Fix inconsistent undo