reduce undo/redo memory leak