Changes and fixes for undo-redo