Fix undo with edges