Index: src/Actions/AnalysisAction/PairCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -76,5 +76,5 @@
   ofstream output;
   ofstream binoutput;
-  std::vector< element *> elements;
+  std::vector<const element *> elements;
   string type;
   Vector Point;
Index: src/Actions/AnalysisAction/PointCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PointCorrelationAction.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Actions/AnalysisAction/PointCorrelationAction.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -77,5 +77,5 @@
   ofstream output;
   ofstream binoutput;
-  std::vector< element *> elements;
+  std::vector<const element *> elements;
   string type;
   Vector Point;
@@ -97,5 +97,5 @@
   cout << "Point to correlate to is  " << Point << endl;
   CorrelationToPointMap *correlationmap = NULL;
-  for(std::vector< element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
+  for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
     cout << "element is " << (*iter)->getSymbol() << endl;
   std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
Index: src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -78,5 +78,5 @@
   ofstream output;
   ofstream binoutput;
-  std::vector< element *> elements;
+  std::vector<const element *> elements;
   string type;
   Vector Point;
Index: src/Actions/AtomAction/AddAction.cpp
===================================================================
--- src/Actions/AtomAction/AddAction.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Actions/AtomAction/AddAction.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -52,5 +52,5 @@
 
 Action::state_ptr AtomAddAction::performCall() {
-  element * elemental = NULL;
+  const element * elemental = NULL;
   Vector position;
 
Index: src/Actions/AtomAction/ChangeElementAction.cpp
===================================================================
--- src/Actions/AtomAction/ChangeElementAction.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Actions/AtomAction/ChangeElementAction.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -50,5 +50,5 @@
 Action::state_ptr AtomChangeElementAction::performCall() {
   atom *first = NULL;
-  element *elemental = NULL;
+  const element *elemental = NULL;
 
   ValueStorage::getInstance().queryCurrentValue(NAME, elemental);
Index: src/Actions/MapOfActions.cpp
===================================================================
--- src/Actions/MapOfActions.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Actions/MapOfActions.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -292,5 +292,5 @@
 
   // value types for the actions
-  TypeMap["add-atom"] = &typeid(element);
+  TypeMap["add-atom"] = &typeid(const element);
   TypeMap["bond-file"] = &typeid(std::string);
   TypeMap["bond-table"] = &typeid(std::string);
@@ -298,5 +298,5 @@
   TypeMap["center-in-box"] = &typeid(BoxValue);
   TypeMap["change-box"] = &typeid(BoxValue);
-  TypeMap["change-element"] = &typeid(element);
+  TypeMap["change-element"] = &typeid(const element);
   TypeMap["change-molname"] = &typeid(std::string);
   TypeMap["convex-envelope"] = &typeid(void);
@@ -342,6 +342,6 @@
   TypeMap["distances"] = &typeid(VectorValue);
   TypeMap["DoRotate"] = &typeid(bool);
-  TypeMap["element"] = &typeid(element);
-  TypeMap["elements"] = &typeid(std::vector<element *>);
+  TypeMap["element"] = &typeid(const element);
+  TypeMap["elements"] = &typeid(std::vector<const element *>);
   TypeMap["end-step"] = &typeid(int);
   TypeMap["id-mapping"] = &typeid(bool);
@@ -380,6 +380,6 @@
   TypeEnumMap[&typeid(atom)] = Atom;
   TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
-  TypeEnumMap[&typeid(element)] = Element;
-  TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
+  TypeEnumMap[&typeid(const element)] = Element;
+  TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
 
   // default values for any action that needs one (always string!)
@@ -558,7 +558,7 @@
 }
 
-void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
+void MapOfActions::queryCurrentValue(const char * name, const element * &_T)  {
   int Z = -1;
-  if (typeid( element ) == *TypeMap[name]) {
+  if (typeid(const element ) == *TypeMap[name]) {
     if (CurrentValue.find(name) == CurrentValue.end())
       throw MissingValueException(__FILE__, __LINE__);
@@ -642,9 +642,9 @@
 }
 
-void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
+void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
 {
   int Z = -1;
-  element *elemental = NULL;
-  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
+  const element *elemental = NULL;
+  if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     if (CurrentValue.find(name) == CurrentValue.end())
       throw MissingValueException(__FILE__, __LINE__);
@@ -694,7 +694,7 @@
 }
 
-void MapOfActions::setCurrentValue(const char * name, class element * &_T)
-{
-  if (typeid( element ) == *TypeMap[name]) {
+void MapOfActions::setCurrentValue(const char * name, const element * &_T)
+{
+  if (typeid(const element ) == *TypeMap[name]) {
     std::ostringstream stream;
     stream << _T->Z;
@@ -754,9 +754,9 @@
 }
 
-void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
-{
-  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
+void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
+{
+  if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
     std::ostringstream stream;
-    for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
+    for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
       stream << (*iter)->Z << " ";
     }
Index: src/Actions/MapOfActions.hpp
===================================================================
--- src/Actions/MapOfActions.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Actions/MapOfActions.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -163,10 +163,10 @@
 
   void queryCurrentValue(const char * name, class atom * &_T);
-  void queryCurrentValue(const char * name, class element * &_T);
+  void queryCurrentValue(const char * name, const element * &_T);
   void queryCurrentValue(const char * name, class molecule * &_T);
   void queryCurrentValue(const char * name, class Box &_T);
   void queryCurrentValue(const char * name, class Vector &_T);
   void queryCurrentValue(const char * name, std::vector<atom *>&_T);
-  void queryCurrentValue(const char * name, std::vector<element *>&_T);
+  void queryCurrentValue(const char * name, std::vector<const element *>&_T);
   void queryCurrentValue(const char * name, std::vector<molecule *>&_T);
   template<typename T> void queryCurrentValue(const char * name, T &_T)
@@ -197,10 +197,10 @@
 
   void setCurrentValue(const char * name, class atom * &_T);
-  void setCurrentValue(const char * name, class element * &_T);
+  void setCurrentValue(const char * name, const element * &_T);
   void setCurrentValue(const char * name, class molecule * &_T);
   void setCurrentValue(const char * name, class Box &_T);
   void setCurrentValue(const char * name, class Vector &_T);
   void setCurrentValue(const char * name, std::vector<atom *>&_T);
-  void setCurrentValue(const char * name, std::vector<element *>&_T);
+  void setCurrentValue(const char * name, std::vector<const element *>&_T);
   void setCurrentValue(const char * name, std::vector<molecule *>&_T);
   template<class T> void setCurrentValue(const char * name, T &_T)
Index: src/Formula.cpp
===================================================================
--- src/Formula.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/Formula.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -146,5 +146,5 @@
 
 bool Formula::hasElement(const string &shorthand) const{
-  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
   return hasElement(element);
 }
@@ -167,5 +167,5 @@
 
 void Formula::operator+=(const string &shorthand){
-  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
   operator+=(element);
 }
@@ -198,5 +198,5 @@
 
 void Formula::operator-=(const string &shorthand){
-  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
   operator-=(element);
 }
@@ -220,5 +220,5 @@
 
 void Formula::addElements(const string &shorthand,unsigned int count){
-  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
   addElements(element,count);
 }
@@ -252,5 +252,5 @@
 
 const unsigned int Formula::operator[](string shorthand) const{
-  element * element = World::getInstance().getPeriode()->FindElement(shorthand);
+  const element * element = World::getInstance().getPeriode()->FindElement(shorthand);
   return operator[](element);
 }
@@ -380,5 +380,5 @@
 result_type
 Formula::_iterator<result_type>::operator*(){
-  element *element = World::getInstance().getPeriode()->FindElement(pos+1);
+  const element *element = World::getInstance().getPeriode()->FindElement(pos+1);
   ASSERT(element,"Element with position of iterator not found");
   return make_pair(element,(*set)[pos]);
@@ -390,5 +390,5 @@
   // no one can keep this value around, so a static is ok to avoid temporaries
   static value_type value=make_pair(reinterpret_cast<element*>(0),0); // no default constructor for std::pair
-  element *element = World::getInstance().getPeriode()->FindElement(pos+1);
+  const element *element = World::getInstance().getPeriode()->FindElement(pos+1);
   ASSERT(element,"Element with position of iterator not found");
   value = make_pair(element,(*set)[pos]);
Index: src/UIElements/Dialog.hpp
===================================================================
--- src/UIElements/Dialog.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/UIElements/Dialog.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -255,5 +255,5 @@
     virtual void setResult();
   protected:
-    element * tmp;
+    const element * tmp;
   };
 
@@ -265,6 +265,6 @@
     virtual void setResult();
   protected:
-    element *temp;
-    std::vector<element *> tmp;
+    const element *temp;
+    std::vector<const element *> tmp;
   };
 
Index: src/UIElements/QT4/QTDialog.cpp
===================================================================
--- src/UIElements/QT4/QTDialog.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/UIElements/QT4/QTDialog.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -818,5 +818,5 @@
 }
 
-ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) :
+ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) :
   content(_content),
   dialog(_dialog),
@@ -834,5 +834,5 @@
 }
 
-ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
+ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
   content(_content),
   dialog(_dialog),
@@ -846,5 +846,5 @@
   QVariant data = theBox->itemData(newIndex);
   int idx = data.toInt();
-  element *elemental = World::getInstance().getPeriode()->FindElement(idx);
+  const element *elemental = World::getInstance().getPeriode()->FindElement(idx);
   if(elemental)
     (*content).push_back(elemental);
Index: src/UIElements/QT4/QTDialog.hpp
===================================================================
--- src/UIElements/QT4/QTDialog.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/UIElements/QT4/QTDialog.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -451,5 +451,5 @@
   Q_OBJECT
 public:
-  ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox);
+  ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox);
   virtual ~ElementQTQueryPipe();
 
@@ -458,5 +458,5 @@
 
 private:
-  element **content;
+  const element **content;
   QTDialog *dialog;
   QComboBox *theBox;
@@ -466,5 +466,5 @@
   Q_OBJECT
 public:
-  ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox);
+  ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox);
   virtual ~ElementsQTQueryPipe();
 
@@ -473,5 +473,5 @@
 
 private:
-  std::vector<element *>*content;
+  std::vector<const element *>*content;
   QTDialog *dialog;
   QComboBox *theBox;
Index: src/UIElements/TextUI/TextDialog.cpp
===================================================================
--- src/UIElements/TextUI/TextDialog.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/UIElements/TextUI/TextDialog.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -566,5 +566,5 @@
   bool badInput=false;
   bool aborted = false;
-  element * temp = NULL;
+  const element * temp = NULL;
   do{
     badInput = false;
Index: src/analysis_correlation.cpp
===================================================================
--- src/analysis_correlation.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/analysis_correlation.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -32,5 +32,5 @@
  * \return Map of doubles with values the pair of the two atoms.
  */
-PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements)
+PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements)
 {
   Info FunctionInfo(__func__);
@@ -47,16 +47,16 @@
 
   // create all possible pairs of elements
-  set <pair<element *, element *> > PairsOfElements;
+  set <pair<const element *,const element *> > PairsOfElements;
   if (elements.size() >= 2) {
-    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
-      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
+    for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
+      for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
         if (type1 != type2) {
-          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
+          PairsOfElements.insert( make_pair(*type1,*type2) );
           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
         }
   } else if (elements.size() == 1) { // one to all are valid
-    element *elemental = *elements.begin();
-    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
-    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
+    const element *elemental = *elements.begin();
+    PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
+    PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
   } else { // all elements valid
     PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
@@ -73,5 +73,5 @@
           DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
           if ((*iter)->getId() < (*runner)->getId()){
-            for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
+            for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
               if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
                 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node);
@@ -94,5 +94,5 @@
  * \return Map of doubles with values the pair of the two atoms.
  */
-PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
+PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] )
 {
   Info FunctionInfo(__func__);
@@ -114,16 +114,16 @@
 
   // create all possible pairs of elements
-  set <pair<element *, element *> > PairsOfElements;
+  set <pair<const element *,const element *> > PairsOfElements;
   if (elements.size() >= 2) {
-    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
-      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
+    for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
+      for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
         if (type1 != type2) {
-          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
+          PairsOfElements.insert( make_pair(*type1,*type2) );
           DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl);
         }
   } else if (elements.size() == 1) { // one to all are valid
-    element *elemental = *elements.begin();
-    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
-    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
+    const element *elemental = *elements.begin();
+    PairsOfElements.insert( pair<const element *,const element*>(elemental,0) );
+    PairsOfElements.insert( pair<const element *,const element*>(0,elemental) );
   } else { // all elements valid
     PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
@@ -148,5 +148,5 @@
                   DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
                   if ((*iter)->getId() < (*runner)->getId()){
-                    for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
+                    for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
                       if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
                         periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3
@@ -177,5 +177,5 @@
  * \return Map of dobules with values as pairs of atom and the vector
  */
-CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point )
+CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point )
 {
   Info FunctionInfo(__func__);
@@ -195,5 +195,5 @@
     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
       DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
         if ((*type == NULL) || ((*iter)->type == *type)) {
           distance = domain.periodicDistance(*(*iter)->node,*point);
@@ -214,5 +214,5 @@
  * \return Map of dobules with values as pairs of atom and the vector
  */
-CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
+CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] )
 {
   Info FunctionInfo(__func__);
@@ -236,5 +236,5 @@
     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
       DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
         if ((*type == NULL) || ((*iter)->type == *type)) {
           periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
@@ -262,5 +262,5 @@
  * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
  */
-CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
+CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
 {
   Info FunctionInfo(__func__);
@@ -283,5 +283,5 @@
     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
       DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl);
-      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
         if ((*type == NULL) || ((*iter)->type == *type)) {
           TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
@@ -308,5 +308,5 @@
  * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
  */
-CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
+CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
 {
   Info FunctionInfo(__func__);
@@ -334,5 +334,5 @@
     for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
       DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-      for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
+      for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
         if ((*type == NULL) || ((*iter)->type == *type)) {
           periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3
Index: src/analysis_correlation.hpp
===================================================================
--- src/analysis_correlation.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/analysis_correlation.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -46,10 +46,10 @@
 /********************************************** declarations *******************************/
 
-PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements);
-CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point );
-CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
-PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
-CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
-CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
+PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements);
+CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point );
+CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
+PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] );
+CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] );
+CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
 int GetBin ( const double value, const double BinWidth, const double BinStart );
 void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
Index: src/periodentafel.cpp
===================================================================
--- src/periodentafel.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/periodentafel.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -34,5 +34,5 @@
   {
     stringstream input(elementsDB,ios_base::in);
-    bool status = LoadElementsDatabase(&input);
+    bool status = LoadElementsDatabase(input);
     ASSERT(status,  "General element initialization failed");
   }
@@ -72,5 +72,5 @@
  * \return iterator to added element
  */
-periodentafel::iterator periodentafel::AddElement(element * const pointer)
+periodentafel::iterator periodentafel::AddElement(element * pointer)
 {
   atomicNumber_t Z = pointer->getNumber();
@@ -85,5 +85,5 @@
  * \param *pointer element to be removed
  */
-size_t periodentafel::RemoveElement(element * const pointer)
+size_t periodentafel::RemoveElement(const element * pointer)
 {
   return RemoveElement(pointer->getNumber());
@@ -113,5 +113,5 @@
  * \return pointer to element or NULL if not found
  */
-element * const periodentafel::FindElement(atomicNumber_t Z) const
+const element * periodentafel::FindElement(atomicNumber_t Z) const
 {
   const_iterator res = elements.find(Z);
@@ -124,5 +124,5 @@
  * \return pointer to element
  */
-element * const periodentafel::FindElement(const string &shorthand) const
+const element * periodentafel::FindElement(const string &shorthand) const
 {
   element *res = 0;
@@ -139,7 +139,7 @@
  * \return desired element or NULL
  */
-element * const periodentafel::AskElement() const
-{
-  element * walker = NULL;
+const element * periodentafel::AskElement() const
+{
+  const element * walker = NULL;
   int Z;
   do {
@@ -154,10 +154,10 @@
  * \return pointer to either present or newly created element
  */
-element * const periodentafel::EnterElement()
+const element * periodentafel::EnterElement()
 {
   atomicNumber_t Z = 0;
   DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
   cin >> Z;
-  element * const res = FindElement(Z);
+  const element *res = FindElement(Z);
   if (!res) {
     // TODO: make this using the constructor
@@ -179,17 +179,17 @@
 
 /******************** Access to iterators ****************************/
-periodentafel::const_iterator periodentafel::begin(){
+periodentafel::const_iterator periodentafel::begin() const{
   return elements.begin();
 }
 
-periodentafel::const_iterator periodentafel::end(){
+periodentafel::const_iterator periodentafel::end() const{
   return elements.end();
 }
 
-periodentafel::reverse_iterator periodentafel::rbegin(){
+periodentafel::reverse_iterator periodentafel::rbegin() const{
   return reverse_iterator(elements.end());
 }
 
-periodentafel::reverse_iterator periodentafel::rend(){
+periodentafel::reverse_iterator periodentafel::rend() const{
   return reverse_iterator(elements.begin());
 }
@@ -227,5 +227,5 @@
   if (!input.fail())
     DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
-  status = status && LoadElementsDatabase(&input);
+  status = status && LoadElementsDatabase(input);
   input.close();
   input.clear();
@@ -286,49 +286,41 @@
  * \return true - parsing successful, false - something went wrong
  */
-bool periodentafel::LoadElementsDatabase(istream *input)
+bool periodentafel::LoadElementsDatabase(istream &input)
 {
   bool status = true;
-  int counter = 0;
-  pair< std::map<atomicNumber_t,element*>::iterator, bool > InserterTest;
-  if (!(*input).fail()) {
-    (*input).getline(header1, MAXSTRINGSIZE);
-    (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines
+  string header1tmp,header2tmp;
+  // first parse into a map, so we can revert to old status in case something goes wront
+  map<atomicNumber_t,element*> parsedElements;
+  if (!input.fail()) {
+    getline(input,header1tmp);
+    getline(input,header2tmp); // skip first two header lines
+    cout << "First header: " << header1tmp << endl;
+    cout << "Second header: " << header2tmp << endl;
     DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
-    while (!(*input).eof()) {
+    while (!input.eof()) {
       element *neues = new element;
-      (*input) >> neues->getName();;
-      //(*input) >> ws;
-      (*input) >> neues->getSymbol();
-      //(*input) >> ws;
-      (*input) >> neues->period;
-      //(*input) >> ws;
-      (*input) >> neues->group;
-      //(*input) >> ws;
-      (*input) >> neues->block;
-      //(*input) >> ws;
-      (*input) >> neues->Z;
-      //(*input) >> ws;
-      (*input) >> neues->mass;
-      //(*input) >> ws;
-      (*input) >> neues->CovalentRadius;
-      //(*input) >> ws;
-      (*input) >> neues->VanDerWaalsRadius;
-      //(*input) >> ws;
-      (*input) >> ws;
+      input >> neues->getName();;
+      //(*input) >> ws;
+      input >> neues->getSymbol();
+      //(*input) >> ws;
+      input >> neues->period;
+      //(*input) >> ws;
+      input >> neues->group;
+      //(*input) >> ws;
+      input >> neues->block;
+      //(*input) >> ws;
+      input >> neues->Z;
+      //(*input) >> ws;
+      input >> neues->mass;
+      //(*input) >> ws;
+      input >> neues->CovalentRadius;
+      //(*input) >> ws;
+      input >> neues->VanDerWaalsRadius;
+      //(*input) >> ws;
+      input >> ws;
       //neues->Output((ofstream *)&cout);
       if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
-        if (elements.count(neues->getNumber())) {// if element already present, remove and delete old one (i.e. replace it)
-          //cout << neues->symbol << " is present already." << endl;
-          element * const Elemental = FindElement(neues->getNumber());
-          ASSERT(Elemental != NULL, "element should be present but is not??");
-          *Elemental = *neues;
-          delete(neues);
-          neues = Elemental;
-        } else {
-          InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues));
-          ASSERT(InserterTest.second, "Could not insert new element into periodentafel on LoadElementsDatabase().");
-        }
+        parsedElements[neues->Z] = neues;
         DoLog(0) && (Log() << Verbose(0) << " " << *neues);
-        counter++;
       } else {
         DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
@@ -336,4 +328,10 @@
         delete(neues);
       }
+      // when the input is in failed state, we most likely just read garbage
+      if(input.fail()) {
+        DoeLog(2) && (eLog() << Verbose(2) << "Error parsing elements db." << endl);
+        status = false;
+        break;
+      }
     }
     DoLog(0) && (Log() << Verbose(0) << endl);
@@ -343,6 +341,27 @@
   }
 
-  if (counter == 0)
+  if (!parsedElements.size())
     status = false;
+
+  if(status){
+    for(map<atomicNumber_t,element*>::iterator iter=parsedElements.begin();
+                                               iter!=parsedElements.end();
+                                               ++iter){
+      if (elements.count(iter->first)) {
+        // if element already present, replace the old one
+        // pointer to old element might still be in use, so we have to replace into the old element
+        *(elements[iter->first])=*iter->second;
+      }
+      else {
+        // no such element in periodentafel... we can just insert
+        elements[iter->first] = iter->second;
+      }
+    }
+    // all went well.. we now copy the header
+    strncpy(header1,header1tmp.c_str(),MAXSTRINGSIZE);
+    header1[MAXSTRINGSIZE-1]=0;
+    strncpy(header2,header2tmp.c_str(),MAXSTRINGSIZE);
+    header2[MAXSTRINGSIZE-1]=0;
+  }
 
   return status;
Index: src/periodentafel.hpp
===================================================================
--- src/periodentafel.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/periodentafel.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -43,17 +43,17 @@
   ~periodentafel();
 
-  iterator AddElement(element * const pointer);
-  size_t RemoveElement(element * const pointer);
+  iterator AddElement(element * pointer);
+  size_t RemoveElement(const element * pointer);
   size_t RemoveElement(atomicNumber_t);
   void CleanupPeriodtable();
-  element * const FindElement(atomicNumber_t) const;
-  element * const FindElement(const std::string &shorthand) const;
-  element * const AskElement() const;
-  element * const EnterElement();
+  const element * FindElement(atomicNumber_t) const;
+  const element * FindElement(const std::string &shorthand) const;
+  const element * AskElement() const;
+  const element * EnterElement();
 
-  const_iterator begin();
-  const_iterator end();
-  reverse_iterator rbegin();
-  reverse_iterator rend();
+  const_iterator begin() const;
+  const_iterator end() const;
+  reverse_iterator rbegin() const;
+  reverse_iterator rend() const;
   bool Output(std::ostream * const output) const;
   bool LoadPeriodentafel(const char * const path);
@@ -62,5 +62,5 @@
   private:
 
-  bool LoadElementsDatabase(std::istream *input);
+  bool LoadElementsDatabase(std::istream &input);
   bool LoadValenceDatabase(std::istream *input);
   bool LoadOrbitalsDatabase(std::istream *input);
Index: src/unittests/AnalysisCorrelationToPointUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -46,5 +46,5 @@
 
   // construct element list
-  std::vector<element *> elements;
+  std::vector<const element *> elements;
   hydrogen = World::getInstance().getPeriode()->FindElement(1);
   CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
Index: src/unittests/AnalysisCorrelationToPointUnitTest.hpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -37,5 +37,5 @@
       std::vector<molecule *> allMolecules;
       molecule *TestMolecule;
-      element *hydrogen;
+      const element *hydrogen;
 
       CorrelationToPointMap *pointmap;
Index: src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -45,7 +45,7 @@
       std::vector<molecule *> allMolecules;
       molecule *TestSurfaceMolecule;
-      element *hydrogen;
-      element *carbon;
-      std::vector<element *> elements;
+      const element *hydrogen;
+      const element *carbon;
+      std::vector<const element *> elements;
 
       CorrelationToSurfaceMap *surfacemap;
Index: src/unittests/AnalysisPairCorrelationUnitTest.cpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -49,5 +49,5 @@
 
   // construct element list
-  std::vector<element *> elements;
+  std::vector<const element *> elements;
   hydrogen = World::getInstance().getPeriode()->FindElement(1);
   CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
Index: src/unittests/AnalysisPairCorrelationUnitTest.hpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/unittests/AnalysisPairCorrelationUnitTest.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -37,5 +37,5 @@
       std::vector<molecule *> allMolecules;
       molecule *TestMolecule;
-      element *hydrogen;
+      const element *hydrogen;
 
       PairCorrelationMap *correlationmap;
Index: src/unittests/periodentafelTest.cpp
===================================================================
--- src/unittests/periodentafelTest.cpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/unittests/periodentafelTest.cpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -11,4 +11,7 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+
+#include <sstream>
+#include <iostream>
 
 #include "Helpers/Assert.hpp"
@@ -67,5 +70,6 @@
 {
   // reload all databases
-  CPPUNIT_ASSERT(tafel->LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)) && "General element initialization failed");
+  stringstream elementsDBstream(elementsDB,ios_base::in);
+  CPPUNIT_ASSERT(tafel->LoadElementsDatabase(elementsDBstream) && "General element initialization failed");
   CPPUNIT_ASSERT(tafel->LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)) && "Valence entry of element initialization failed");
   CPPUNIT_ASSERT(tafel->LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)) && "Orbitals entry of element initialization failed");
Index: src/unittests/periodentafelTest.hpp
===================================================================
--- src/unittests/periodentafelTest.hpp	(revision 2a76b0d2f8f171ff646f96c33fad3043938bdb23)
+++ src/unittests/periodentafelTest.hpp	(revision e5c0a1f2c378f5ba38776b0cbdd720632338e25c)
@@ -31,6 +31,6 @@
 private:
 
-      element *hydrogen;
-      element *carbon;
+      const element *hydrogen;
+      const element *carbon;
       periodentafel *tafel;
 
