Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp	(revision beadd01e38c8b43b7e036136cab8a85e047de252)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp	(revision 9176598b2abdf3b63b4901d8c0078619f061e6fb)
@@ -53,14 +53,19 @@
 #include "WorldTime.hpp"
 
-GLMoleculeObject_atom::GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atom *atomref) :
+GLMoleculeObject_atom::GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atomId_t _id) :
   GLMoleculeObject(mesh, parent),
-  Observer(std::string("GLMoleculeObject_atom")+toString(atomref->getId())),
-  _atom(atomref)
+  Observer(std::string("GLMoleculeObject_atom")+toString(_id)),
+  atomicid(_id)
 {
   // sign on as observer (obtain non-const instance before)
-  atomref->signOn(this, AtomObservable::IndexChanged);
-  atomref->signOn(this, AtomObservable::PositionChanged);
-  atomref->signOn(this, AtomObservable::ElementChanged);
-  atomref->signOn(this, AtomObservable::BondsAdded);
+  const atom *_atom = World::getInstance().getAtom(AtomById(atomicid));
+  if (_atom != NULL) {
+    _atom->signOn(this, AtomObservable::IndexChanged);
+    _atom->signOn(this, AtomObservable::PositionChanged);
+    _atom->signOn(this, AtomObservable::ElementChanged);
+    _atom->signOn(this, AtomObservable::BondsAdded);
+  } else {
+    ELOG(2, "Atom with id "+toString(atomicid)+" is already gone.");
+  }
   World::getInstance().signOn(this, World::SelectionChanged);
   WorldTime::getInstance().signOn(this, WorldTime::TimeChanged);
@@ -69,5 +74,5 @@
   resetProperties();
 
-  LOG(2, "INFO: Created sphere for atom " << _atom->getId() << ".");
+  LOG(2, "INFO: Created sphere for atom " << atomicid << ".");
 
   connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
@@ -76,5 +81,6 @@
 GLMoleculeObject_atom::~GLMoleculeObject_atom()
 {
-  if (_atom){
+  const atom *_atom = World::getInstance().getAtom(AtomById(atomicid));
+  if (_atom != NULL){
     _atom->signOff(this, AtomObservable::IndexChanged);
     _atom->signOff(this, AtomObservable::PositionChanged);
@@ -89,5 +95,5 @@
 {
 #ifdef LOG_OBSERVER
-  observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(static_cast<Observer *>(this)) << " from atom "+toString(_atom->getId())+".";
+  observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(static_cast<Observer *>(this)) << " from atom "+toString(atomicid)+".";
 #endif
   resetProperties();
@@ -96,7 +102,12 @@
 void GLMoleculeObject_atom::resetPosition()
 {
-  const Vector Position = _atom->getPosition();
-  LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+".");
-  setPosition(QVector3D(Position[0], Position[1], Position[2]));
+  const atom *_atom = World::getInstance().getAtom(AtomById(atomicid));
+  if (_atom != NULL) {
+    const Vector Position = _atom->getPosition();
+    LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+".");
+    setPosition(QVector3D(Position[0], Position[1], Position[2]));
+  } else {
+    ELOG(2, "Atom with id "+toString(atomicid)+" is already gone.");
+  }
 }
 
@@ -104,25 +115,31 @@
 {
   size_t elementno = 0;
-  if (_atom->getType() != NULL) {
-    elementno = _atom->getType()->getAtomicNumber();
-  } else { // if no element yet, set to hydrogen
-    elementno = 1;
-  }
-  LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new element number is "+toString(elementno)+".");
-
-  // set materials
-  QGLMaterial *elementmaterial = getMaterial(elementno);
-  ASSERT(elementmaterial != NULL,
-      "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function is NULL.");
-  setMaterial(elementmaterial);
-
-  // set scale
-  double radius = 0.;
-  if (_atom->getType() != NULL) {
-    radius = _atom->getType()->getVanDerWaalsRadius();
-  } else {
-    radius = 0.5;
-  }
-  setScale( radius / 4. );
+  const atom *_atom = World::getInstance().getAtom(AtomById(atomicid));
+  if (_atom != NULL) {
+    const element *_type = _atom->getType();
+    if (_type != NULL) {
+      elementno = _type->getAtomicNumber();
+    } else { // if no element yet, set to hydrogen
+      elementno = 1;
+    }
+    LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new element number is "+toString(elementno)+".");
+
+    // set materials
+    QGLMaterial *elementmaterial = getMaterial(elementno);
+    ASSERT(elementmaterial != NULL,
+        "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function is NULL.");
+    setMaterial(elementmaterial);
+
+    // set scale
+    double radius = 0.;
+    if (_type != NULL) {
+      radius = _type->getVanDerWaalsRadius();
+    } else {
+      radius = 0.5;
+    }
+    setScale( radius / 4. );
+  } else {
+    ELOG(2, "Atom with id "+toString(atomicid)+" is already gone.");
+  }
 }
 
@@ -130,9 +147,8 @@
 {
   int oldId = objectId();
-  const size_t atomno = _atom->getId();
-  LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new index is "+toString(atomno)+".");
-  setObjectId(atomno);
-
-  emit indexChanged(this, oldId, atomno);
+  LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new index is "+toString(atomicid)+".");
+  setObjectId(atomicid);
+
+  emit indexChanged(this, oldId, atomicid);
 }
 
@@ -149,14 +165,16 @@
 
   // selected?
-  setSelected(World::getInstance().isSelected(_atom));
+  setSelected(World::getInstance().isAtomSelected(atomicid));
 }
 
 void GLMoleculeObject_atom::subjectKilled(Observable *publisher)
 {
-  _atom = NULL;
+  // remove id such that we don't sign off accidentally from a different atom
+  const_cast<atomId_t &>(atomicid) = -1;
 }
 
 void GLMoleculeObject_atom::recieveNotification(Observable *publisher, Notification_ptr notification)
 {
+  const atom *_atom = World::getInstance().getAtom(AtomById(atomicid));
   if (publisher == dynamic_cast<const Observable*>(_atom)){
     // notofication from atom
@@ -180,4 +198,6 @@
       case AtomObservable::BondsAdded:
       {
+        const atom *_atom = World::getInstance().getAtom(AtomById(atomicid));
+        if (_atom != NULL) {
           ASSERT(!_atom->getListOfBonds().empty(),
               "GLMoleculeObject_atom::recieveNotification() - received BondsAdded but ListOfBonds is empty.");
@@ -186,6 +206,9 @@
               GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;
           emit BondsInserted(_bond, side);
-          break;
+        } else {
+          ELOG(2, "Atom with id "+toString(atomicid)+" is already gone.");
         }
+        break;
+      }
       default:
         //setProperties();
@@ -226,5 +249,5 @@
 void GLMoleculeObject_atom::wasClicked()
 {
-  LOG(4, "INFO: GLMoleculeObject_atom: atom " << _atom->getId() << " has been clicked");
-  emit clicked(_atom->getId());
-}
+  LOG(4, "INFO: GLMoleculeObject_atom: atom " << atomicid << " has been clicked");
+  emit clicked(atomicid);
+}
Index: src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp	(revision beadd01e38c8b43b7e036136cab8a85e047de252)
+++ src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp	(revision 9176598b2abdf3b63b4901d8c0078619f061e6fb)
@@ -19,7 +19,6 @@
 
 #include "Bond/bond.hpp"
-#include "GLMoleculeObject_bond.hpp"
-
-class atom;
+#include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp"
+#include "types.hpp"
 
 class GLMoleculeObject_atom : public GLMoleculeObject, public Observer
@@ -27,5 +26,5 @@
   Q_OBJECT
 public:
-  GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atom *atomref);
+  GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atomId_t id);
   virtual ~GLMoleculeObject_atom();
 
@@ -51,5 +50,5 @@
   void resetProperties();
 
-  const atom *_atom;
+  const atomId_t atomicid;
 };
 
Index: src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
===================================================================
--- src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision beadd01e38c8b43b7e036136cab8a85e047de252)
+++ src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp	(revision 9176598b2abdf3b63b4901d8c0078619f061e6fb)
@@ -145,9 +145,8 @@
 {
   LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_id)+".");
-  const atom *_atom = World::getInstance().getAtom(AtomById(_id));
-  GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(meshSphere, this, _atom);
+  GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(meshSphere, this, _id);
   AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);
   ASSERT(iter == AtomsinSceneMap.end(),
-      "GLWorldScene::atomAdded() - same atom "+_atom->getName()+" added again.");
+      "GLWorldScene::atomAdded() - same atom "+toString(_id)+" added again.");
   AtomsinSceneMap.insert( make_pair(_id, atomObject) );
 
