Bug fixes in undo/redo when connecting/disconnecting a viewer