Index: src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp
===================================================================
--- src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp	(revision 59f1bcc899a181c8225110eb43adbf27eb563d57)
+++ src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp	(revision 23221f089340ed3767f2e9a84cf97029b3012e2b)
@@ -87,111 +87,17 @@
 
 private:
-  /** \note CountedObservedValues_t needs to contain a list in the second argument
-   * as the ObservedValuesContainer may fall behind when a single atom is created
-   * and destroyed a number of times in a row (e.g. in the undo/redo cases). This
-   * problem is inherent because on the one hand we keep the QtObservedAtom alive
-   * till the last moment, i.e. till the GUI does not need it anymore where the
-   * original instance may long have been removed from the World. On the other hand
-   * we instantiate the e.g. QtObservedAtom as soon as the observed atom is created.
-   */
 
-  /** Structure to contain the sequence of created observed memories.
-   *
-   * \note QtGUI may lag behind the creation/destruction of observed instances a
-   * lot but one after the other must be served. Here, we keep an additional
-   * iterator that indicates the current instance to be served.
-   */
-  struct RefCountedObserved
-  {
-    typedef std::pair<typename T::ptr, size_t> Value_t;
-    typedef std::deque<Value_t> Values_t;
-
-    /** Default cstor of RefCountedObservedValues.
-     *
-     * Make sure that currentvalue has some sensible default value.
-     */
-    RefCountedObserved() :
-      tobedestroyed(values.end()),
-      currentvalue(values.end())
-    {}
-
-    /** Default copy cstor of RefCountedObservedValues.
-     *
-     * \param _instance instance to copy
-     */
-    RefCountedObserved(const RefCountedObserved & _instance) :
-      values(_instance.values),
-      tobedestroyed(values.begin()),
-      currentvalue(values.begin())
-    {}
-
-    /** Cstor of RefCountedObservedValues.
-     *
-     * Make sure that currentvalue has some sensible default value.
-     *
-     * \param _value initial value for the list
-     */
-    RefCountedObserved(Value_t _value) :
-      values(1, _value),
-      tobedestroyed(values.begin()),
-      currentvalue(values.begin())
-    {}
-
-    bool empty() const
-    {
-      return values.empty();
-    }
-
-    void push_back(Value_t _value)
-    {
-      values.push_back(_value);
-      if (currentvalue == values.end())
-        currentvalue = values.end()--;
-      if (tobedestroyed == values.end())
-        tobedestroyed = currentvalue;
-    }
-
-    Value_t& getCurrentValue() const
-    {
-      ASSERT (currentvalue != values.end(),
-          "RefCountedObservedValues::getCurrentValue() - cannot get, no values present.");
-      return *currentvalue;
-    }
-
-    Value_t& getEraseCandidate() const
-    {
-      ASSERT (tobedestroyed != values.end(),
-          "RefCountedObservedValues::getCurrentValue() - cannot get, no values present.");
-      return *tobedestroyed;
-    }
-
-    void eraseCurrentValue()
-    {
-      ASSERT (tobedestroyed != values.end(),
-          "RefCountedObservedValues::eraseCurrentValue() - cannot erase, no values present.");
-      if (tobedestroyed == currentvalue)
-        ++currentvalue;
-      values.erase(tobedestroyed);
-      tobedestroyed = currentvalue;
-      // removal of this instance when both iterators point to end is done inside QtObservedInstanceBoard
-    }
-
-    //!> set of values
-    Values_t values;
-    //!> iterator on the value that is next gonna be destroyed
-    typename Values_t::iterator tobedestroyed;
-    //!> iterator on the current value that is served on get
-    typename Values_t::iterator currentvalue;
-  };
-
-  typedef std::map<id, RefCountedObserved > CountedObservedValues_t;
+  typedef std::map<id, typename T::ptr > CountedObservedValues_t;
   //!> internal vector of observed values
   CountedObservedValues_t ObservedValues;
 
   //!> typedef for the set with ids to be erase
-  typedef std::set<id> MarkedForErase_t;
+  typedef std::set<id> MarkedSet_t;
 
   //!> marks ids marked for erase (i.e. all subjectKilled() received)
-  MarkedForErase_t MarkedForErase;
+  MarkedSet_t MarkedForErase;
+
+  //!> marks ids marked as connected (i.e. for later subjectKilled() received)
+  MarkedSet_t MarkedForConnected;
 
   //!> name used in describing the instance type
@@ -214,5 +120,5 @@
    * \return true - no more signOn()s, false - else
    */
-  bool checkRefCount(const id _id) const;
+  bool checkMarkedForConnected(const id _id) const;
 
   /** Internal function to check whether the vector of ObservedValue's
Index: src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp
===================================================================
--- src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp	(revision 59f1bcc899a181c8225110eb43adbf27eb563d57)
+++ src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp	(revision 23221f089340ed3767f2e9a84cf97029b3012e2b)
@@ -36,13 +36,6 @@
   boost::recursive_mutex::scoped_lock lock(atomic_mutex);
   for (typename CountedObservedValues_t::iterator iter = ObservedValues.begin();
-      iter != ObservedValues.end(); ++iter) {
-    ASSERT( !iter->second.empty(),
-        "~ObservedValuesContainer() of "+NameOfType+" "+toString(iter->first)
-        +" has an empty list in ObservedValues.");
-    for (typename RefCountedObserved::Values_t::iterator listiter = iter->second.values.begin();
-        listiter != iter->second.values.end(); ++listiter) {
-      listiter->first->noteBoardIsGone();
-    }
-  }
+      iter != ObservedValues.end(); ++iter)
+    iter->second->noteBoardIsGone();
 }
 
@@ -53,5 +46,5 @@
 void ObservedValuesContainer<T,id>::checkRemoval(const id _id)
 {
-  if (checkRefCount(_id) && checkMarkedForErase(_id))
+  if (checkMarkedForConnected(_id) && checkMarkedForErase(_id))
     removeObservedValues(_id);
 }
@@ -67,5 +60,5 @@
     return typename T::ptr();
   else
-    return iter->second.getCurrentValue().first;
+    return iter->second;
 }
 
@@ -77,18 +70,17 @@
   LOG(3, "DEBUG: ObservedValuesContainer got markObservedValuesAsConnected() for an observed value of "
       << NameOfType << " " << _id);
-  typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
-  ASSERT (iter != ObservedValues.end(),
+  ASSERT (MarkedForConnected.find(_id) == MarkedForConnected.end(),
       "ObservedValuesContainer<T,id>::markObservedValuesAsConnected() - Observed value of "
-      +NameOfType+" "+toString(_id)+" is not present yet.");
-  ++(iter->second.getCurrentValue().second);
-}
-
-template <class T, typename id>
-bool ObservedValuesContainer<T,id>::checkRefCount(
+      +NameOfType+" "+toString(_id)+" is already marked as connected.");
+  MarkedForConnected.insert( _id );
+}
+
+template <class T, typename id>
+bool ObservedValuesContainer<T,id>::checkMarkedForConnected(
     const id _id) const
 {
   boost::recursive_mutex::scoped_lock lock(atomic_mutex);
-  typename CountedObservedValues_t::const_iterator iter = ObservedValues.find(_id);
-  return ((iter != ObservedValues.end()) && (iter->second.getEraseCandidate().second == 0));
+  typename MarkedSet_t::const_iterator const iter = MarkedForConnected.find(_id);
+  return iter == MarkedForConnected.end();
 }
 
@@ -100,12 +92,9 @@
   LOG(3, "DEBUG: ObservedValuesContainer got markObservedValuesAsDisconnected() for an observed value of "
       << NameOfType << " " << _id);
-  typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
-  ASSERT (iter != ObservedValues.end(),
+  typename MarkedSet_t::iterator const iter = MarkedForConnected.find(_id);
+  ASSERT (iter != MarkedForConnected.end(),
       "ObservedValuesContainer<T,id>::markObservedValuesAsDisconnected() - Observed value of "
-      +NameOfType+" "+toString(_id)+" is not present yet.");
-  ASSERT (iter->second.getEraseCandidate().second != 0,
-      "ObservedValuesContainer<T,id>::markObservedValuesAsDisconnected() - Observed value of "
-      +NameOfType+" "+toString(_id)+" is already signOff() from all.");
-  --(iter->second.getEraseCandidate().second);
+      +NameOfType+" "+toString(_id)+" is not marked as connected.");
+  MarkedForConnected.erase(iter);
 
   checkRemoval(_id);
@@ -117,11 +106,9 @@
   boost::recursive_mutex::scoped_lock lock(atomic_mutex);
   LOG(3, "DEBUG: ObservedValuesContainer removes " << NameOfType << " " << _id);
+  MarkedForConnected.erase(_id);
+  MarkedForErase.erase(_id);
+  ObservedValues.erase(_id);
   // call callback function
   onDestroy(_id);
-  typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
-  iter->second.eraseCurrentValue();
-  if (iter->second.empty())
-    ObservedValues.erase(iter);
-  MarkedForErase.erase(_id);
 }
 
@@ -148,5 +135,6 @@
 {
   boost::recursive_mutex::scoped_lock lock(atomic_mutex);
-  return MarkedForErase.count(_id);
+  typename MarkedSet_t::const_iterator const iter = MarkedForErase.find(_id);
+  return iter != MarkedForErase.end();
 }
 
@@ -155,20 +143,15 @@
 {
   boost::recursive_mutex::scoped_lock lock(atomic_mutex);
-  typename ObservedValuesContainer<T,id>::RefCountedObserved::Value_t value(std::make_pair(_obsvalues,0));
   typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);
-  if (iter == ObservedValues.end()) {
-    std::pair<typename CountedObservedValues_t::iterator, bool> inserter =
-        ObservedValues.insert(
-            std::make_pair( _id, RefCountedObserved(value) ) );
-    ASSERT( inserter.second,
-        "ObservedValuesContainer<T,id>::insert() of "+NameOfType
-        +" for "+toString(_id)+", insertion failed though empty?");
-  } else {
-    ASSERT( !iter->second.empty(),
-        "ObservedValuesContainer<T,id>::insert() of "+NameOfType
-        +" for "+toString(_id)+" has an empty list in ObservedValues.");
-    // already an entry present? add to deque
-    iter->second.push_back( value );
-  }
+  ASSERT (iter == ObservedValues.end(),
+      "ObservedValuesContainer<T,id>::insert() of "+NameOfType
+      +" for "+toString(_id)+" failed because "+toString(_id)+" already present.");
+  std::pair<typename CountedObservedValues_t::iterator, bool> inserter =
+      ObservedValues.insert(
+          std::make_pair( _id, _obsvalues ) );
+  ASSERT( inserter.second,
+      "ObservedValuesContainer<T,id>::insert() of "+NameOfType
+      +" for "+toString(_id)+", insertion failed though empty?");
+
   _obsvalues->activateObserver();
 }
@@ -180,8 +163,11 @@
   const typename CountedObservedValues_t::iterator Colditer = ObservedValues.find(_oldid);
   const typename CountedObservedValues_t::iterator Cnewiter = ObservedValues.find(_newid);
-  const typename MarkedForErase_t::iterator Eolditer = MarkedForErase.find(_oldid);
-  const typename MarkedForErase_t::iterator Enewiter = MarkedForErase.find(_newid);
+  const typename MarkedSet_t::iterator MEolditer = MarkedForErase.find(_oldid);
+  const typename MarkedSet_t::iterator MEnewiter = MarkedForErase.find(_newid);
+  const typename MarkedSet_t::iterator MColditer = MarkedForConnected.find(_oldid);
+  const typename MarkedSet_t::iterator MCnewiter = MarkedForConnected.find(_newid);
   bool status = ((Colditer != ObservedValues.end()) && (Cnewiter == ObservedValues.end()));
-  status &= ((Eolditer != MarkedForErase.end()) && (Enewiter == MarkedForErase.end()));
+  status &= ((MEolditer != MarkedForErase.end()) && (MEnewiter == MarkedForErase.end()));
+  status &= ((MColditer != MarkedForConnected.end()) && (MCnewiter == MarkedForConnected.end()));
   // change id here only if still present
   if (status) {
@@ -192,11 +178,15 @@
       // whether changing ids "there" is possible when the QtObserved... is under
       // removal.
-      ObservedValuesContainer<T,id>::RefCountedObserved obsvalues = Colditer->second;
+      typename T::ptr obsvalues = Colditer->second;
       ObservedValues.erase(Colditer);
       ObservedValues.insert( std::make_pair(_newid, obsvalues) );
     }
     {
-      MarkedForErase.erase(Eolditer);
+      MarkedForErase.erase(MEolditer);
       MarkedForErase.insert(_newid);
+    }
+    {
+      MarkedForConnected.erase(MColditer);
+      MarkedForConnected.insert(_newid);
     }
     return true;
