Bugfix in undo/redo logic