Fix undo stack completely