Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp	(revision 3fe31809465087526b25224aaeb6783b78d555b6)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp	(revision 7ded1c2e6b5dc07f58723eaa1665215ba1d857b4)
@@ -361,32 +361,35 @@
   LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomInserted for atom "+toString(_id)+".");
 
-  GLMoleculeObject_atom *atomObject =
-      new GLMoleculeObject_atom(
-          GLMoleculeObject::meshSphere,
-          this,
-          board.getObservedAtom(_id));
-  ASSERT( atomObject != NULL,
-      "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString(_id));
-  AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);
-  ASSERT(iter == AtomsinSceneMap.end(),
-      "GLMoleculeObject_molecule::atomInserted - same atom with id "+toString(_id)+" added again.");
-  AtomsinSceneMap.insert( make_pair(_id, atomObject) );
-
-  qRegisterMetaType<atomId_t>("atomId_t");
-  qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond");
-  connect (atomObject, SIGNAL(clicked(atomId_t)), this, SIGNAL(atomClicked(atomId_t)));
-  connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));
-  connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
-  connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
-//  connect (atomObject, SIGNAL(bondsChanged()), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
-  connect (atomObject, SIGNAL(BondsAdded(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
-  connect (atomObject, SIGNAL(BondsRemoved(const atomId_t, const atomId_t)), this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
-  connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, const atomId_t, const atomId_t)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, const atomId_t, const atomId_t)));
-
-  if (m_objectId  == -1)
-    setObjectId(_id);
-
-  emit changed();
-  emit changeOccured();
+  const QtObservedAtom::ptr _atom = board.getObservedAtom(_id);
+  if (_atom) {
+    GLMoleculeObject_atom *atomObject =
+        new GLMoleculeObject_atom(
+            GLMoleculeObject::meshSphere,
+            this,
+            _atom);
+    ASSERT( atomObject != NULL,
+        "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString(_id));
+    AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);
+    ASSERT(iter == AtomsinSceneMap.end(),
+        "GLMoleculeObject_molecule::atomInserted - same atom with id "+toString(_id)+" added again.");
+    AtomsinSceneMap.insert( make_pair(_id, atomObject) );
+
+    qRegisterMetaType<atomId_t>("atomId_t");
+    qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond");
+    connect (atomObject, SIGNAL(clicked(atomId_t)), this, SIGNAL(atomClicked(atomId_t)));
+    connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));
+    connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));
+    connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));
+  //  connect (atomObject, SIGNAL(bondsChanged()), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
+    connect (atomObject, SIGNAL(BondsAdded(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond)));
+    connect (atomObject, SIGNAL(BondsRemoved(const atomId_t, const atomId_t)), this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
+    connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, const atomId_t, const atomId_t)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, const atomId_t, const atomId_t)));
+
+    if (m_objectId  == -1)
+      setObjectId(_id);
+
+    emit changed();
+    emit changeOccured();
+  }
 }
 
Index: src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision 3fe31809465087526b25224aaeb6783b78d555b6)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision 7ded1c2e6b5dc07f58723eaa1665215ba1d857b4)
@@ -223,54 +223,39 @@
   // add new object
   LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _id);
-  GLMoleculeObject_molecule *molObject =
-      new GLMoleculeObject_molecule(
-          GLMoleculeObject::meshEmpty,
-          this,
-          *board,
-          board->getObservedMolecule(_id));
-  ASSERT( molObject != NULL,
-      "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id));
-  MoleculesinSceneMap.insert( make_pair(_id, molObject) );
-
-  // now handle all state changes that came up before the instantiation
-  while (MoleculeMissedStateMap.count(_id) != 0) {
-    ASSERT( !MoleculeMissedStateMap[_id].empty(),
-        "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id "
-        +toString(_id));
-    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
-    for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin();
-        !MoleculeMissedStateMap[_id].empty();
-        iter = MoleculeMissedStateMap[_id].begin()) {
-      std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter =
-          MoleculeMissedStateMap[_id].equal_range(iter->first);
-      const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second);
-      if (StateCounts > 1) {
-        // more than one state change, have to combine
-        typedef std::map<StateChangeType, size_t> StateChangeAmounts_t;
-        StateChangeAmounts_t StateChangeAmounts;
-        for (StateChangeMap_t::const_iterator stateiter = rangeiter.first;
-            stateiter != rangeiter.second; ++stateiter)
-          ++StateChangeAmounts[stateiter->second];
-        ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState],
-            "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom "
-            +toString(iter->first));
-        if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) {
-          LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
-          QMetaObject::invokeMethod(molObject,        // pointer to a QObject
-                                    "atomInserted",       // member name (no parameters here)
-                                    Qt::QueuedConnection,     // connection type
-                                    Q_ARG(const atomId_t, iter->first));     // parameters
-        } else {
-          LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already.");
-        }
-      } else {
-        // can only be an insertion
-        switch (rangeiter.first->second) {
-          case atomRemovedState:
-            ASSERT( 0,
-                "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom "
-                +toString(iter->first));
-            break;
-          case atomInsertedState:
+  const QtObservedMolecule::ptr mol = board->getObservedMolecule(_id);
+  if (mol) {
+    GLMoleculeObject_molecule *molObject =
+        new GLMoleculeObject_molecule(
+            GLMoleculeObject::meshEmpty,
+            this,
+            *board,
+            mol);
+    ASSERT( molObject != NULL,
+        "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id));
+    MoleculesinSceneMap.insert( make_pair(_id, molObject) );
+
+    // now handle all state changes that came up before the instantiation
+    while (MoleculeMissedStateMap.count(_id) != 0) {
+      ASSERT( !MoleculeMissedStateMap[_id].empty(),
+          "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id "
+          +toString(_id));
+      boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
+      for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin();
+          !MoleculeMissedStateMap[_id].empty();
+          iter = MoleculeMissedStateMap[_id].begin()) {
+        std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter =
+            MoleculeMissedStateMap[_id].equal_range(iter->first);
+        const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second);
+        if (StateCounts > 1) {
+          // more than one state change, have to combine
+          typedef std::map<StateChangeType, size_t> StateChangeAmounts_t;
+          StateChangeAmounts_t StateChangeAmounts;
+          for (StateChangeMap_t::const_iterator stateiter = rangeiter.first;
+              stateiter != rangeiter.second; ++stateiter)
+            ++StateChangeAmounts[stateiter->second];
+          ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState],
+              "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom "
+              +toString(iter->first));
+          if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) {
             LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
             QMetaObject::invokeMethod(molObject,        // pointer to a QObject
@@ -278,30 +263,52 @@
                                       Qt::QueuedConnection,     // connection type
                                       Q_ARG(const atomId_t, iter->first));     // parameters
-            break;
-          default:
-            ASSERT( 0,
-                "GLWorldScene::moleculeInserted() - there are unknown change states.");
-            break;
+          } else {
+            LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already.");
+          }
+        } else {
+          // can only be an insertion
+          switch (rangeiter.first->second) {
+            case atomRemovedState:
+              ASSERT( 0,
+                  "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom "
+                  +toString(iter->first));
+              break;
+            case atomInsertedState:
+              LOG(1, "INFO: invoking atomInserted for atom " << iter->first);
+              QMetaObject::invokeMethod(molObject,        // pointer to a QObject
+                                        "atomInserted",       // member name (no parameters here)
+                                        Qt::QueuedConnection,     // connection type
+                                        Q_ARG(const atomId_t, iter->first));     // parameters
+              break;
+            default:
+              ASSERT( 0,
+                  "GLWorldScene::moleculeInserted() - there are unknown change states.");
+              break;
+          }
         }
+        // removed state changes for this atom
+        MoleculeMissedStateMap[_id].erase(iter);
       }
-      // removed state changes for this atom
-      MoleculeMissedStateMap[_id].erase(iter);
     }
-    // remove state change map for the molecule
+
+    connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
+    connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
+    connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
+    connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));
+    connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
+    connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
+    connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
+    connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
+    connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
+
+    emit changed();
+    emit changeOccured();
+  }
+
+  // remove state change map for the molecule
+  {
+    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     MoleculeMissedStateMap.erase(_id);
   }
-
-  connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
-  connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));
-  connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
-  connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));
-  connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
-  connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
-  connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
-  connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
-  connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
-
-  emit changed();
-  emit changeOccured();
 }
 
