Index: src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision 6e1628b7373c59c6545f88f455af8d047506193e)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision 5026148ed739f29b2229d07be76ad31aca20fe30)
@@ -164,5 +164,5 @@
     const ObservedValue_Index_t atomid = _atom->getIndex();
     boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
-    AtomNodeParentMap[atomid] = static_cast<QObject *>(this);
+    AtomNodeParentMap.insert( std::make_pair(atomid, (ObservedValue_Index_t)NULL) );
   }
 
@@ -185,8 +185,12 @@
     boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex);
     AtomNodeParentMap_t::iterator parentiter = AtomNodeParentMap.find(atomid);
-    if (parentiter != AtomNodeParentMap.end())
-      parent = parentiter->second;
-    else
-      AtomNodeParentMap[atomid] = parent;
+    ASSERT (parentiter != AtomNodeParentMap.end(),
+        "GLWorldScene::insertAtom() - parent to atom id "+toString(atomid)+" unknown?");
+    const ObservedValue_Index_t parentindex = parentiter->second;
+    if (parentindex != (ObservedValue_Index_t)NULL) {
+      const MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentindex);
+      if (moliter != MoleculesinSceneMap.end())
+        parent = moliter->second;
+    }
 
     atomObject = new GLMoleculeObject_atom(
@@ -252,17 +256,9 @@
     const ObservedValue_Index_t bondid = _bond->getIndex();
     boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
-    std::vector<QObject *> parents(2, static_cast<QObject *>(this));
-    if ((_bond->getLeftAtom() != NULL) && (_bond->getLeftAtom()->getMoleculeRef() != NULL)) {
-      const ObservedValue_Index_t molid = _bond->getLeftAtom()->getMoleculeRef()->getIndex();
-      const MoleculeNodeMap::iterator leftiter = MoleculesinSceneMap.find(molid);
-      if (leftiter != MoleculesinSceneMap.end())
-        parents[0] = leftiter->second;
-    }
-    if ((_bond->getRightAtom() != NULL) && (_bond->getRightAtom()->getMoleculeRef() != NULL)) {
-      const ObservedValue_Index_t molid = _bond->getRightAtom()->getMoleculeRef()->getIndex();
-      const MoleculeNodeMap::iterator leftiter = MoleculesinSceneMap.find(molid);
-      if (leftiter != MoleculesinSceneMap.end())
-        parents[1] = leftiter->second;
-    }
+    std::vector<ObservedValue_Index_t> parents(2, (ObservedValue_Index_t)NULL);
+    if ((_bond->getLeftAtom() != NULL) && (_bond->getLeftAtom()->getMoleculeRef() != NULL))
+      parents[0] = _bond->getLeftAtom()->getMoleculeRef()->getIndex();
+    if ((_bond->getRightAtom() != NULL) && (_bond->getRightAtom()->getMoleculeRef() != NULL))
+      parents[1] = _bond->getRightAtom()->getMoleculeRef()->getIndex();
     BondNodeParentMap.insert( std::make_pair(bondid, parents) );
   }
@@ -288,8 +284,14 @@
     boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
     BondNodeParentMap_t::iterator parentiter = BondNodeParentMap.find(bondid);
-    if (parentiter != BondNodeParentMap.end()) {
-      parents = parentiter->second;
-    } else
-      BondNodeParentMap.insert( std::make_pair(bondid, parents) );
+    ASSERT (parentiter != BondNodeParentMap.end(),
+        "GLWorldScene::insertBond() - parent to bond id "+toString(bondid)+" unknown?");
+    const std::vector<ObservedValue_Index_t> &molindices = parentiter->second;
+    for (size_t i = 0; i < molindices.size(); ++i) {
+      if (molindices[i] != (ObservedValue_Index_t)NULL) {
+        const MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molindices[i]);
+        if (moliter != MoleculesinSceneMap.end())
+          parents[i] = moliter->second;
+      }
+    }
 
     BondNodeMap::iterator iter = BondsinSceneMap.find(bondid);
@@ -464,97 +466,103 @@
   ASSERT( parentiter != AtomNodeParentMap.end(),
       "GLWorldScene::reparentAtom() - could not find object to id "+toString(walkerid));
+
+  // change parent entry
+  if (walker->getMoleculeRef() != NULL)
+    parentiter->second = walker->getMoleculeRef()->getIndex();
+  else
+    parentiter->second = NULL;
+  parentiter = AtomNodeParentMap.find(walkerid);
+
+  // reset parent if atom exists
   AtomNodeMap::iterator atomiter = AtomsinSceneMap.find(walkerid);
-  ASSERT( atomiter != AtomsinSceneMap.end(),
-      "GLWorldScene::reparentAtom() - could not find GLMoleculeObject to id "+toString(walkerid));
-  if (walker->getMoleculeRef() != NULL) {
-    const ObservedValue_Index_t molid = walker->getMoleculeRef()->getIndex();
-    MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid);
-    if (moliter != MoleculesinSceneMap.end()) {
-      parentiter->second = moliter->second;
-      atomiter->second->setParent(moliter->second);
-    } else {
-      // associated molecule has not yet been instantiated, keep in mind
-      ASSERT(0,
-          "GLWorldScene::reparentAtom() - new molecule not present yet?");
+  if (atomiter != AtomsinSceneMap.end()) {
+    QObject *parent = this;
+    if (parentiter->second != NULL) {
+      MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentiter->second);
+      if (moliter != MoleculesinSceneMap.end())
+        parent = moliter->second;
+      else {
+        // molecule does not yet exist
+        ASSERT(0, "GLWorldScene::reparentAtom() - molecule not existent not implemented.");
+      }
     }
-  } else {
-    parentiter->second = static_cast<QObject*>(this);
-    atomiter->second->setParent(this);
-  }
+    atomiter->second->setParent(parent);
+  }
+}
+
+/** Changes the parent of an left-side bond in the scene.
+ *
+ */
+void GLWorldScene::reparentBondLeft()
+{
+  boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
+  QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender());
+  reparentBond(bond, bond->getLeftAtom(), GLMoleculeObject_bond::left);
+}
+
+/** Changes the parent of an right-side bond in the scene.
+ *
+ */
+void GLWorldScene::reparentBondRight()
+{
+  boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
+  QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender());
+  reparentBond(bond, bond->getRightAtom(), GLMoleculeObject_bond::right);
+}
+
+GLMoleculeObject_bond *GLWorldScene::getBondInScene(
+    const ObservedValue_Index_t _bondid,
+    GLMoleculeObject_bond::SideOfBond _side) const
+{
+  std::pair<GLWorldScene::BondNodeMap::const_iterator, GLWorldScene::BondNodeMap::const_iterator> iters =
+      BondsinSceneMap.equal_range(_bondid);
+  ASSERT( std::distance(iters.first, iters.second) == 2,
+      "GLWorldScene::getBondInScene() - not exactly two bonds of same id "
+      +toString(_bondid)+" present in scene.");
+  for (GLWorldScene::BondNodeMap::const_iterator bonditer = iters.first;
+      bonditer != iters.second; ++bonditer) {
+    if (bonditer->second->BondSide == _side)
+      return bonditer->second;
+  }
+  return NULL;
 }
 
 /** Changes the parent of an object in the scene.
  *
- * \param _id index of the object whose parent to change
- * \param _ob new parent
- */
-void GLWorldScene::reparentBondLeft()
-{
-  QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender());
+ * \param _atom atom of bond whose molecule we are associated to
+ * \param _side side of bond
+ */
+void GLWorldScene::reparentBond(
+    QtObservedBond *_bond,
+    const QtObservedAtom * const _atom,
+    const GLMoleculeObject_bond::SideOfBond _side)
+{
   boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
-  const ObservedValue_Index_t bondid = bond->getIndex();
+  const ObservedValue_Index_t bondid = _bond->getIndex();
   BondNodeParentMap_t::iterator parentiter = BondNodeParentMap.find(bondid);
   ASSERT( parentiter != BondNodeParentMap.end(),
-      "GLWorldScene::reparentBondLeft() - could not find object to id "+toString(bondid));
-  BondNodeMap::iterator bonditer = BondsinSceneMap.find(bondid);
-  ASSERT( bonditer != BondsinSceneMap.end(),
-      "GLWorldScene::reparentBondLeft() - could not find GLMoleculeObject to id "+toString(bondid));
-  if (bonditer->second->BondSide != GLMoleculeObject_bond::left)
-    ++bonditer;
-  ASSERT( (bonditer->first == bondid)
-      && (bonditer->second->BondSide == GLMoleculeObject_bond::left),
-      "GLWorldScene::reparentBondLeft() - could not find left-side bond.");
-  if ((bond->getLeftAtom() != NULL) && (bond->getLeftAtom()->getMoleculeRef() != NULL)) {
-    const ObservedValue_Index_t molid = bond->getLeftAtom()->getMoleculeRef()->getIndex();
-    MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid);
-    if (moliter != MoleculesinSceneMap.end()) {
-      parentiter->second[0] = moliter->second;
-      bonditer->second->setParent(moliter->second);
-    } else {
-      // associated molecule has not yet been instantiated, keep in mind
-      ASSERT(0,
-          "GLWorldScene::reparentBondLeft() - new molecule not present yet?");
+      "GLWorldScene::reparentBond() - could not find object to id "+toString(bondid));
+
+  // change parent entry
+  const size_t dim = (_side == GLMoleculeObject_bond::left) ? 0 : 1;
+  if ((_atom != NULL) && (_atom->getMoleculeRef() != NULL))
+    parentiter->second[dim] = _atom->getMoleculeRef()->getIndex();
+  else
+    parentiter->second[dim] = NULL;
+
+  // reset parent
+  GLMoleculeObject_bond *bondobj = getBondInScene(bondid, _side);
+  if (bondobj != NULL) {
+    QObject *parent = this;
+    if (parentiter->second[dim] != NULL) {
+      MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentiter->second[dim]);
+      if (moliter != MoleculesinSceneMap.end())
+        parent = moliter->second;
+      else {
+        // molecule does not yet exist
+        ASSERT(0, "GLWorldScene::reparentAtom() - molecule not existent not implemented.");
+      }
     }
-  } else {
-    parentiter->second[0] = static_cast<QObject*>(this);
-    bonditer->second->setParent(this);
-  }
-}
-
-/** Changes the parent of an object in the scene.
- *
- * \param _id index of the object whose parent to change
- * \param _ob new parent
- */
-void GLWorldScene::reparentBondRight()
-{
-  QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender());
-  boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex);
-  const ObservedValue_Index_t bondid = bond->getIndex();
-  BondNodeParentMap_t::iterator parentiter = BondNodeParentMap.find(bondid);
-  ASSERT( parentiter != BondNodeParentMap.end(),
-      "GLWorldScene::reparentBondLeft() - could not find object to id "+toString(bondid));
-  BondNodeMap::iterator bonditer = BondsinSceneMap.find(bondid);
-  ASSERT( bonditer != BondsinSceneMap.end(),
-      "GLWorldScene::reparentBondLeft() - could not find GLMoleculeObject to id "+toString(bondid));
-  if (bonditer->second->BondSide != GLMoleculeObject_bond::right)
-    ++bonditer;
-  ASSERT( (bonditer->first == bondid)
-      && (bonditer->second->BondSide == GLMoleculeObject_bond::right),
-      "GLWorldScene::reparentBondLeft() - could not find right-side bond.");
-  if ((bond->getRightAtom() != NULL) && (bond->getRightAtom()->getMoleculeRef() != NULL)) {
-    const ObservedValue_Index_t molid = bond->getRightAtom()->getMoleculeRef()->getIndex();
-    MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid);
-    if (moliter != MoleculesinSceneMap.end()) {
-      parentiter->second[1] = moliter->second;
-      bonditer->second->setParent(moliter->second);
-    } else {
-      // associated molecule has not yet been instantiated, keep in mind
-      ASSERT(0,
-          "GLWorldScene::reparentBondRight() - new molecule not present yet?");
-    }
-  } else {
-    parentiter->second[1] = static_cast<QObject*>(this);
-    bonditer->second->setParent(this);
+    bondobj->setParent(parent);
   }
 }
Index: src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp	(revision 6e1628b7373c59c6545f88f455af8d047506193e)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp	(revision 5026148ed739f29b2229d07be76ad31aca20fe30)
@@ -116,4 +116,14 @@
   void reparentBondRight();
 
+private:
+  void reparentBond(
+      QtObservedBond *_bond,
+      const QtObservedAtom * const _atom,
+      const GLMoleculeObject_bond::SideOfBond _side);
+
+  GLMoleculeObject_bond *getBondInScene(
+      const ObservedValue_Index_t _bondid,
+      GLMoleculeObject_bond::SideOfBond _side) const;
+
 public:
   void updateSelectedShapes();
@@ -129,7 +139,8 @@
   typedef std::map< std::string , GLMoleculeObject_shape* > ShapeNodeMap;
 
-  //!> typedef for storing the current parent to each node in scene
-  typedef std::map<ObservedValue_Index_t, QObject *> AtomNodeParentMap_t;
-  typedef std::map<ObservedValue_Index_t, std::vector<QObject *> > BondNodeParentMap_t;
+  //!> typedef for storing the current parent to each atom node in scene, NULL indicates GLWorldScene is parent
+  typedef std::map<ObservedValue_Index_t, ObservedValue_Index_t> AtomNodeParentMap_t;
+  //!> typedef for storing the current parent to each bond node in scene, NULL indicates GLWorldScene is parent
+  typedef std::map<ObservedValue_Index_t, std::vector<ObservedValue_Index_t> > BondNodeParentMap_t;
 
   //!> mutex to ascertain atomic access to NodeParentMaps
