Index: src/Actions/AnalysisAction/DipoleAngularCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/DipoleAngularCorrelationAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/AnalysisAction/DipoleAngularCorrelationAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -21,6 +21,4 @@
 
 #include "Analysis/analysis_correlation.hpp"
-#include "Tesselation/boundary.hpp"
-#include "linkedcell.hpp"
 #include "CodePatterns/Log.hpp"
 #include "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp"
@@ -29,5 +27,7 @@
 #include "Element/periodentafel.hpp"
 #include "LinearAlgebra/Vector.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "molecule.hpp"
+#include "Tesselation/boundary.hpp"
 #include "World.hpp"
 #include "WorldTime.hpp"
Index: src/Actions/AnalysisAction/DipoleCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/DipoleCorrelationAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/AnalysisAction/DipoleCorrelationAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -25,5 +25,5 @@
 #include "Element/periodentafel.hpp"
 #include "LinearAlgebra/Vector.hpp"
-#include "linkedcell.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "molecule.hpp"
 #include "World.hpp"
Index: src/Actions/AnalysisAction/MolecularVolumeAction.cpp
===================================================================
--- src/Actions/AnalysisAction/MolecularVolumeAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/AnalysisAction/MolecularVolumeAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -20,11 +20,11 @@
 #include "CodePatterns/MemDebug.hpp"
 
-#include "Tesselation/boundary.hpp"
 #include "config.hpp"
-#include "molecule.hpp"
-#include "linkedcell.hpp"
 #include "CodePatterns/Log.hpp"
 #include "CodePatterns/Verbose.hpp"
-#include "PointCloudAdaptor.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
+#include "molecule.hpp"
+#include "Tesselation/boundary.hpp"
 #include "Tesselation/tesselation.hpp"
 #include "World.hpp"
Index: src/Actions/AnalysisAction/PairCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/AnalysisAction/PairCorrelationAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -21,6 +21,4 @@
 
 #include "Analysis/analysis_correlation.hpp"
-#include "Tesselation/boundary.hpp"
-#include "linkedcell.hpp"
 #include "CodePatterns/Verbose.hpp"
 #include "CodePatterns/Log.hpp"
@@ -29,4 +27,5 @@
 #include "Element/periodentafel.hpp"
 #include "LinearAlgebra/Vector.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "World.hpp"
 
Index: src/Actions/AnalysisAction/PointCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/PointCorrelationAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/AnalysisAction/PointCorrelationAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -21,12 +21,11 @@
 
 #include "Analysis/analysis_correlation.hpp"
-#include "Tesselation/boundary.hpp"
-#include "linkedcell.hpp"
 #include "CodePatterns/Verbose.hpp"
 #include "CodePatterns/Log.hpp"
 #include "Element/element.hpp"
-#include "molecule.hpp"
 #include "Element/periodentafel.hpp"
 #include "LinearAlgebra/Vector.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "molecule.hpp"
 #include "World.hpp"
 
Index: src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp
===================================================================
--- src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -21,14 +21,13 @@
 
 #include "Analysis/analysis_correlation.hpp"
-#include "Tesselation/boundary.hpp"
-#include "linkedcell.hpp"
-#include "CodePatterns/Verbose.hpp"
 #include "CodePatterns/Log.hpp"
 #include "Descriptors/MoleculeIdDescriptor.hpp"
 #include "Element/element.hpp"
+#include "Element/periodentafel.hpp"
 #include "LinearAlgebra/Vector.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "molecule.hpp"
-#include "Element/periodentafel.hpp"
-#include "PointCloudAdaptor.hpp"
+#include "Tesselation/boundary.hpp"
 #include "Tesselation/tesselation.hpp"
 #include "World.hpp"
Index: src/Actions/TesselationAction/ConvexEnvelopeAction.cpp
===================================================================
--- src/Actions/TesselationAction/ConvexEnvelopeAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/TesselationAction/ConvexEnvelopeAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -20,11 +20,10 @@
 #include "CodePatterns/MemDebug.hpp"
 
+#include "CodePatterns/Log.hpp"
+#include "config.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
+#include "molecule.hpp"
 #include "Tesselation/boundary.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "config.hpp"
-#include "linkedcell.hpp"
-#include "molecule.hpp"
-#include "PointCloudAdaptor.hpp"
 #include "Tesselation/tesselation.hpp"
 #include "World.hpp"
Index: src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
===================================================================
--- src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -20,10 +20,9 @@
 #include "CodePatterns/MemDebug.hpp"
 
+#include "CodePatterns/Log.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
+#include "molecule.hpp"
 #include "Tesselation/boundary.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "linkedcell.hpp"
-#include "molecule.hpp"
-#include "PointCloudAdaptor.hpp"
 #include "Tesselation/tesselation.hpp"
 #include "World.hpp"
Index: src/Analysis/unittests/AnalysisCorrelationToPointUnitTest.cpp
===================================================================
--- src/Analysis/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Analysis/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -27,13 +27,11 @@
 
 #include "Analysis/analysis_correlation.hpp"
-
+#include "atom.hpp"
 #include "Descriptors/MoleculeDescriptor.hpp"
-
-#include "atom.hpp"
 #include "Element/element.hpp"
+#include "Element/periodentafel.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "molecule.hpp"
 #include "MoleculeListClass.hpp"
-#include "linkedcell.hpp"
-#include "Element/periodentafel.hpp"
 #include "World.hpp"
 
Index: src/Analysis/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
===================================================================
--- src/Analysis/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Analysis/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -28,13 +28,13 @@
 #include "Analysis/analysis_correlation.hpp"
 #include "atom.hpp"
-#include "Tesselation/boundary.hpp"
 #include "CodePatterns/Assert.hpp"
 #include "Descriptors/MoleculeDescriptor.hpp"
 #include "Element/element.hpp"
+#include "Element/periodentafel.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "molecule.hpp"
 #include "MoleculeListClass.hpp"
-#include "linkedcell.hpp"
-#include "Element/periodentafel.hpp"
-#include "PointCloudAdaptor.hpp"
+#include "Tesselation/boundary.hpp"
 #include "Tesselation/tesselation.hpp"
 #include "World.hpp"
Index: src/Analysis/unittests/AnalysisPairCorrelationUnitTest.cpp
===================================================================
--- src/Analysis/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Analysis/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -29,13 +29,10 @@
 #include "Descriptors/MoleculeDescriptor.hpp"
 
-#include "World.hpp"
 #include "atom.hpp"
 #include "Element/element.hpp"
 #include "Element/periodentafel.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "molecule.hpp"
 #include "MoleculeListClass.hpp"
-#include "linkedcell.hpp"
-#include "Tesselation/boundary.hpp"
-#include "Tesselation/tesselation.hpp"
 #include "World.hpp"
 
Index: src/Fragmentation/analyzer.cpp
===================================================================
--- src/Fragmentation/analyzer.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Fragmentation/analyzer.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -103,6 +103,9 @@
 
   // Test the given directory
-  if (!TestParams(argc, argv))
+  if (!TestParams(argc, argv)) {
+    delete dir;
+    delete periode;
     return 1;
+  }
 
   // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
Index: src/Graph/BondGraph.cpp
===================================================================
--- src/Graph/BondGraph.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Graph/BondGraph.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -197,5 +197,5 @@
                   const TesselPointSTLList *OtherList = LC.GetRelativeToCurrentCell(n);
                   if (OtherList != NULL) {
-                    LOG(3, "INFO: Current relative cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << LC.index << " containing " << List->size() << " points.");
+                    LOG(3, "INFO: Current relative cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << LC.index << " containing " << OtherList->size() << " points.");
                     for (TesselPointSTLList::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
                       if ((*OtherRunner) > Walker) {  // just to not add bonds from both sides
Index: src/Graph/BondGraph.hpp
===================================================================
--- src/Graph/BondGraph.hpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Graph/BondGraph.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -27,10 +27,9 @@
 #include "CodePatterns/Log.hpp"
 #include "CodePatterns/Range.hpp"
-#include "CodePatterns/Verbose.hpp"
 #include "Element/element.hpp"
 #include "Fragmentation/MatrixContainer.hpp"
-#include "linkedcell.hpp"
-#include "IPointCloud.hpp"
-#include "PointCloudAdaptor.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/IPointCloud.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "WorldTime.hpp"
 
Index: c/IPointCloud.hpp
===================================================================
--- src/IPointCloud.hpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ 	(revision )
@@ -1,35 +1,0 @@
-/*
- * IPointCloud.hpp
- *
- *  Created on: Jul 29, 2010
- *      Author: heber
- */
-
-#ifndef IPOINTCLOUD_HPP_
-#define IPOINTCLOUD_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string>
-
-class TesselPoint;
-class Vector;
-
-/** Encapsulates a set of TesselPoints with an internal iterator.
- */
-struct IPointCloud {
-public:
-  virtual const std::string& GetName() const=0;
-  virtual Vector *GetCenter() const=0;
-  virtual TesselPoint *GetPoint()=0;
-  virtual int GetMaxId() const=0;
-  virtual void GoToNext()=0;
-  virtual void GoToFirst()=0;
-  virtual bool IsEmpty() const=0;
-  virtual bool IsEnd() const=0;
-};
-
-#endif /* IPOINTCLOUD_HPP_ */
Index: src/LinkedCell/IPointCloud.hpp
===================================================================
--- src/LinkedCell/IPointCloud.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
+++ src/LinkedCell/IPointCloud.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -0,0 +1,35 @@
+/*
+ * IPointCloud.hpp
+ *
+ *  Created on: Jul 29, 2010
+ *      Author: heber
+ */
+
+#ifndef IPOINTCLOUD_HPP_
+#define IPOINTCLOUD_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+
+class TesselPoint;
+class Vector;
+
+/** Encapsulates a set of TesselPoints with an internal iterator.
+ */
+struct IPointCloud {
+public:
+  virtual const std::string& GetName() const=0;
+  virtual Vector *GetCenter() const=0;
+  virtual TesselPoint *GetPoint()=0;
+  virtual int GetMaxId() const=0;
+  virtual void GoToNext()=0;
+  virtual void GoToFirst()=0;
+  virtual bool IsEmpty() const=0;
+  virtual bool IsEnd() const=0;
+};
+
+#endif /* IPOINTCLOUD_HPP_ */
Index: src/LinkedCell/PointCloudAdaptor.hpp
===================================================================
--- src/LinkedCell/PointCloudAdaptor.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
+++ src/LinkedCell/PointCloudAdaptor.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -0,0 +1,98 @@
+/*
+ * PointCloudAdaptor.hpp
+ *
+ *  Created on: Feb 21, 2011
+ *      Author: heber
+ */
+
+#ifndef POINTCLOUDADAPTOR_HPP_
+#define POINTCLOUDADAPTOR_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Assert.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinkedCell/IPointCloud.hpp"
+#include "Tesselation/TesselPoint.hpp"
+
+/** Adaptor class to IPointCloud, specialized for all needed classes.
+ */
+template <class container_type,
+          class iterator_type = typename container_type::iterator>
+class PointCloudAdaptor: public IPointCloud
+{
+public:
+  PointCloudAdaptor(container_type *_list, const std::string _name) :
+    list(_list),
+    name(_name)
+  {}
+  virtual ~PointCloudAdaptor()
+  {
+    list = NULL;
+  }
+
+  const std::string& GetName() const
+  {
+    return name;
+  }
+  Vector *GetCenter() const
+  {
+    Vector *Center = new Vector(0., 0., 0.);
+    int num = 0;
+    for (iterator_type iter = iterator_type(list->begin());
+        iter != iterator_type(list->end());
+        ++iter) {
+      (*Center) += ((*iter)->getPosition());
+      num++;
+    }
+    Center->Scale(1. / num);
+    return Center;
+  }
+
+  TesselPoint *GetPoint()
+  {
+    ASSERT(!IsEnd(), "PointCloudAdaptor<T>::getPoint() - invalid InternalIterator.");
+    return (*InternalIterator)->getTesselPoint();
+  }
+  int GetMaxId() const
+  {
+    int maxid = -1;
+    for (iterator_type iter = iterator_type(list->begin());
+        iter != iterator_type(list->end());
+        ++iter) {
+      if ((maxid == -1) || ((*iter)->getNr() > maxid)) {
+        maxid = (*iter)->getNr();
+      }
+    }
+    return maxid;
+  }
+  void GoToNext()
+  {
+    if (InternalIterator != iterator_type(list->end()))
+      ++InternalIterator;
+  }
+  void GoToFirst()
+  {
+    InternalIterator = iterator_type(list->begin());
+  }
+  bool IsEmpty() const
+  {
+    return list->begin() == list->end();
+  }
+  bool IsEnd() const
+  {
+    return InternalIterator == iterator_type(list->end());
+  }
+
+private:
+  container_type *list;
+  iterator_type InternalIterator;
+  const std::string name;
+};
+
+
+
+#endif /* POINTCLOUDADAPTOR_HPP_ */
Index: src/LinkedCell/linkedcell.cpp
===================================================================
--- src/LinkedCell/linkedcell.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
+++ src/LinkedCell/linkedcell.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -0,0 +1,358 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010-2011 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/** \file linkedcell.cpp
+ *
+ * Function implementations for the class LinkedCell.
+ *
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "linkedcell.hpp"
+
+#include "atom.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "CodePatterns/Range.hpp"
+#include "CodePatterns/Log.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinkedCell/IPointCloud.hpp"
+#include "molecule.hpp"
+#include "Tesselation/tesselation.hpp"
+
+// ========================================================= class LinkedCell ===========================================
+
+/** Constructor for class LinkedCell.
+ */
+LinkedCell::LinkedCell() :
+  LC(NULL),
+  RADIUS(0.),
+  index(-1)
+{
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  max.Zero();
+  min.Zero();
+};
+
+/** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS
+ * \param *set LCNodeSet class with all LCNode's
+ * \param RADIUS edge length of cells
+ */
+LinkedCell::LinkedCell(IPointCloud & set, const double radius) :
+  LC(NULL),
+  RADIUS(radius),
+  index(-1)
+{
+  TesselPoint *Walker = NULL;
+
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  max.Zero();
+  min.Zero();
+  LOG(1, "Begin of LinkedCell");
+  if (set.IsEmpty()) {
+    ELOG(1, "set is NULL or contains no linked cell nodes!");
+    return;
+  }
+  // 1. find max and min per axis of atoms
+  set.GoToFirst();
+  Walker = set.GetPoint();
+  for (int i=0;i<NDIM;i++) {
+    max[i] = Walker->at(i);
+    min[i] = Walker->at(i);
+  }
+  set.GoToFirst();
+  while (!set.IsEnd()) {
+    Walker = set.GetPoint();
+    for (int i=0;i<NDIM;i++) {
+      if (max[i] < Walker->at(i))
+        max[i] = Walker->at(i);
+      if (min[i] > Walker->at(i))
+        min[i] = Walker->at(i);
+    }
+    set.GoToNext();
+  }
+  LOG(2, "Bounding box is " << min << " and " << max << ".");
+
+  // 2. find then number of cells per axis
+  for (int i=0;i<NDIM;i++) {
+    N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);
+  }
+  LOG(2, "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << ".");
+
+  // 3. allocate the lists
+  LOG(2, "INFO: Allocating cells ... ");
+  if (LC != NULL) {
+    ELOG(1, "Linked Cell list is already allocated, I do nothing.");
+    return;
+  }
+  ASSERT(N[0]*N[1]*N[2] < MAX_LINKEDCELLNODES, "Number linked of linked cell nodes exceded hard-coded limit, use greater edge length!");
+  LC = new TesselPointSTLList[N[0]*N[1]*N[2]];
+  for (index=0;index<N[0]*N[1]*N[2];index++) {
+    LC [index].clear();
+  }
+  LOG(0, "done.");
+
+  // 4. put each atom into its respective cell
+  LOG(2, "INFO: Filling cells ... ");
+  set.GoToFirst();
+  while (!set.IsEnd()) {
+    Walker = set.GetPoint();
+    for (int i=0;i<NDIM;i++) {
+      n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
+    }
+    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    LC[index].push_back(Walker);
+    //LOG(2, *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << ".");
+    set.GoToNext();
+  }
+  LOG(0, "done.");
+  LOG(1, "End of LinkedCell");
+};
+
+
+/** Destructor for class LinkedCell.
+ */
+LinkedCell::~LinkedCell()
+{
+  if (LC != NULL)
+  for (index=0;index<N[0]*N[1]*N[2];index++)
+    LC[index].clear();
+  delete[](LC);
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+};
+
+/** Checks whether LinkedCell::n[] is each within [0,N[]].
+ * \return if all in intervals - true, else -false
+ */
+bool LinkedCell::CheckBounds() const
+{
+  bool status = true;
+  for(int i=0;i<NDIM;i++)
+    status = status && ((n[i] >=0) && (n[i] < N[i]));
+//  if (!status)
+//    ELOG(1, "indices are out of bounds!");
+  return status;
+};
+
+/** Checks whether LinkedCell::n[] plus relative offset is each within [0,N[]].
+ * Note that for this check we don't admonish if out of bounds.
+ * \param relative[NDIM] relative offset to current cell
+ * \return if all in intervals - true, else -false
+ */
+bool LinkedCell::CheckBounds(const int relative[NDIM]) const
+{
+  bool status = true;
+  for(int i=0;i<NDIM;i++)
+    status = status && ((n[i]+relative[i] >=0) && (n[i]+relative[i] < N[i]));
+  return status;
+};
+
+
+/** Returns a pointer to the current cell.
+ * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds.
+ */
+const TesselPointSTLList* LinkedCell::GetCurrentCell() const
+{
+  if (CheckBounds()) {
+    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    return (&(LC[index]));
+  } else {
+    return NULL;
+  }
+};
+
+/** Returns a pointer to the current cell.
+ * \param relative[NDIM] offset for each axis with respect to the current cell LinkedCell::n[NDIM]
+ * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds.
+ */
+const TesselPointSTLList* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
+{
+  if (CheckBounds(relative)) {
+    index = (n[0]+relative[0]) * N[1] * N[2] + (n[1]+relative[1]) * N[2] + (n[2]+relative[2]);
+    return (&(LC[index]));
+  } else {
+    return NULL;
+  }
+};
+
+/** Set the index to the cell containing a given Vector *x.
+ * \param *x Vector with coordinates
+ * \return Vector is inside bounding box - true, else - false
+ */
+bool LinkedCell::SetIndexToVector(const Vector & x) const
+{
+  for (int i=0;i<NDIM;i++)
+    n[i] = (int)floor((x.at(i) - min[i])/RADIUS);
+
+  return CheckBounds();
+};
+
+/** Calculates the index for a given LCNode *Walker.
+ * \param *Walker LCNode to set index tos
+ * \return if the atom is also found in this cell - true, else - false
+ */
+bool LinkedCell::SetIndexToNode(const TesselPoint * const Walker) const
+{
+  bool status = false;
+  for (int i=0;i<NDIM;i++) {
+    n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
+  }
+  index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+  if (CheckBounds()) {
+    for (TesselPointSTLList::iterator Runner = LC[index].begin(); Runner != LC[index].end(); Runner++)
+      status = status || ((*Runner) == Walker);
+    return status;
+  } else {
+    ELOG(1, "Node at " << *Walker << " is out of bounds.");
+    return false;
+  }
+};
+
+/** Calculates the interval bounds of the linked cell grid.
+ * \param lower lower bounds
+ * \param upper upper bounds
+ * \param step how deep to check the neighbouring cells (i.e. number of layers to check)
+ */
+void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step) const
+{
+  for (int i=0;i<NDIM;i++) {
+    lower[i] = n[i]-step;
+    if (lower[i] < 0)
+      lower[i] = 0;
+    if (lower[i] >= N[i])
+      lower[i] = N[i]-1;
+    upper[i] = n[i]+step;
+    if (upper[i] >= N[i])
+      upper[i] = N[i]-1;
+    if (upper[i] < 0)
+      upper[i] = 0;
+    //LOG(0, "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]");
+  }
+};
+
+/** Returns a list with all neighbours from the current LinkedCell::index.
+ * \param distance (if no distance, then adjacent cells are taken)
+ * \return list of tesselpoints
+ */
+TesselPointSTLList* LinkedCell::GetallNeighbours(const double distance) const
+{
+  int Nlower[NDIM], Nupper[NDIM];
+  TesselPoint *Walker = NULL;
+  TesselPointSTLList *TesselList = new TesselPointSTLList;
+
+  // then go through the current and all neighbouring cells and check the contained points for possible candidates
+  const int step = (distance == 0) ? 1 : (int)floor(distance/RADIUS + 1.);
+  GetNeighbourBounds(Nlower, Nupper, step);
+
+  for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++)
+    for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++)
+      for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) {
+        const TesselPointSTLList *List = GetCurrentCell();
+        //LOG(1, "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << ".");
+        if (List != NULL) {
+          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+            Walker = *Runner;
+            TesselList->push_back(Walker);
+          }
+        }
+      }
+  return TesselList;
+};
+
+/** Set the index to the cell containing a given Vector *x, which is not inside the LinkedCell's domain
+ * Note that as we have to check distance from every corner of the closest cell, this function is faw more
+ * expensive and if Vector is known to be inside LinkedCell's domain, then SetIndexToVector() should be used.
+ * \param *x Vector with coordinates
+ * \return minimum squared distance of cell to given vector (if inside of domain, distance is 0)
+ */
+double LinkedCell::SetClosestIndexToOutsideVector(const Vector * const x) const
+{
+  for (int i=0;i<NDIM;i++) {
+    n[i] = (int)floor((x->at(i) - min[i])/RADIUS);
+    if (n[i] < 0)
+      n[i] = 0;
+    if (n[i] >= N[i])
+      n[i] = N[i]-1;
+  }
+
+  // calculate distance of cell to vector
+  double distanceSquared = 0.;
+  bool outside = true;  // flag whether x is found in- or outside of LinkedCell's domain/closest cell
+  Vector corner; // current corner of closest cell
+  Vector tester; // Vector pointing from corner to center of closest cell
+  Vector Distance;  // Vector from corner of closest cell to x
+
+  Vector center;  // center of the closest cell
+  for (int i=0;i<NDIM;i++)
+    center[i] = min[i]+((double)n[i]+.5)*RADIUS;
+
+  int c[NDIM];
+  for (c[0]=0;c[0]<=1;c[0]++)
+    for (c[1]=0; c[1]<=1;c[1]++)
+      for (c[2]=0; c[2]<=1;c[2]++) {
+        // set up corner
+        for (int i=0;i<NDIM;i++)
+          corner[i] = min[i]+RADIUS*((double)n[i]+c[i]);
+        // set up distance vector
+        Distance = (*x) - corner;
+        const double dist = Distance.NormSquared();
+        // check whether distance is smaller
+        if (dist< distanceSquared)
+          distanceSquared = dist;
+        // check whether distance vector goes inside or outside
+        tester = center -corner;
+        if (tester.ScalarProduct(Distance) < 0)
+          outside = false;
+      }
+  return (outside ? distanceSquared : 0.);
+};
+
+/** Returns a list of all TesselPoint with distance less than \a radius to \a *Center.
+ * \param radius radius of sphere
+ * \param *center center of sphere
+ * \return list of all points inside sphere
+ */
+TesselPointSTLList* LinkedCell::GetPointsInsideSphere(const double radius, const Vector * const center) const
+{
+  const double radiusSquared = radius*radius;
+  TesselPoint *Walker = NULL;
+  TesselPointSTLList *TesselList = new TesselPointSTLList;
+  TesselPointSTLList *NeighbourList = NULL;
+
+  // set index of LC to center of sphere
+  const double dist = SetClosestIndexToOutsideVector(center);
+  if (dist > 2.*radius) {
+    ELOG(1, "Vector " << *center << " is too far away from any atom in LinkedCell's bounding box.");
+    return TesselList;
+  } else
+    LOG(1, "Distance of closest cell to center of sphere with radius " << radius << " is " << dist << ".");
+
+  // gather all neighbours first, then look who fulfills distance criteria
+  NeighbourList = GetallNeighbours(2.*radius-dist);
+  //LOG(1, "I found " << NeighbourList->size() << " neighbours to check.");
+  if (NeighbourList != NULL) {
+    for (TesselPointSTLList::const_iterator Runner = NeighbourList->begin(); Runner != NeighbourList->end(); Runner++) {
+      Walker = *Runner;
+      //LOG(1, "Current neighbour is at " << *Walker->node << ".");
+      if ((Walker->DistanceSquared(*center) - radiusSquared) < MYEPSILON) {
+        TesselList->push_back(Walker);
+      }
+    }
+    delete(NeighbourList);
+  } else
+    ELOG(2, "Around vector " << *center << " there are no atoms.");
+  return TesselList;
+};
Index: src/LinkedCell/linkedcell.hpp
===================================================================
--- src/LinkedCell/linkedcell.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
+++ src/LinkedCell/linkedcell.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -0,0 +1,82 @@
+/*
+ * linkedcell.hpp
+ *
+ *  If the linked cell should be usable, the class has to inherit LCNodeSet and the nodes (containing the Vectors) have to inherit LCNode. This works well
+ *  for molecule and atom classes.
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef LINKEDCELL_HPP_
+#define LINKEDCELL_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <list>
+#include <vector>
+#include <map>
+
+//#include "CodePatterns/Assert.hpp"
+//#include "CodePatterns/Log.hpp"
+//#include "CodePatterns/Verbose.hpp"
+#include "Helpers/defs.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "World.hpp"
+
+/****************************************** forward declarations *****************************/
+
+class IPointCloud;
+class TesselPoint;
+
+/********************************************** definitions *********************************/
+
+//< Upper bound for number of cell nodes used in sensibility check on allocation.
+enum { MAX_LINKEDCELLNODES = 1000000 };
+
+/********************************************** declarations *******************************/
+
+typedef std::list<TesselPoint *> TesselPointSTLList;
+
+/** Linked Cell class for containing Vectors in real space efficiently.
+ */
+class LinkedCell {
+private:
+
+public:
+    Vector max;       // upper boundary
+    Vector min;       // lower boundary
+    TesselPointSTLList *LC;  // linked cell list
+    double RADIUS;    // cell edge length
+    int N[NDIM];      // number of cells per axis
+    mutable int n[NDIM];      // temporary variable for current cell per axis
+    mutable int index;        // temporary index variable , access by index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+
+    LinkedCell();
+    LinkedCell(IPointCloud &set, const double radius);
+    ~LinkedCell();
+    const TesselPointSTLList* GetCurrentCell()const ;
+    const TesselPointSTLList* GetRelativeToCurrentCell(const int relative[NDIM])const ;
+    bool SetIndexToNode(const TesselPoint * const Walker)const ;
+    bool SetIndexToVector(const Vector &x)const ;
+    double SetClosestIndexToOutsideVector(const Vector * const x) const;
+    bool CheckBounds()const ;
+    bool CheckBounds(const int relative[NDIM])const ;
+    void GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step = 1)const ;
+
+    TesselPointSTLList* GetallNeighbours(const double distance = 0) const;
+    TesselPointSTLList* GetPointsInsideSphere(const double radius, const Vector * const center) const;
+    // not implemented yet
+    bool AddNode(Vector *Walker);
+    bool DeleteNode(Vector *Walker);
+    bool MoveNode(Vector *Walker);
+};
+
+#endif /*LINKEDCELL_HPP_*/
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Makefile.am	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -115,4 +115,12 @@
 	Dynamics/VerletForceIntegration.hpp
 
+LINKEDCELLSOURCE = \
+  LinkedCell/linkedcell.cpp
+
+LINKEDCELLHEADER = \
+  LinkedCell/linkedcell.hpp \
+  LinkedCell/IPointCloud.hpp \
+  LinkedCell/PointCloudAdaptor.hpp
+
 THERMOSTATSOURCE = \
   Thermostats/Berendsen.cpp \
@@ -157,6 +165,4 @@
   Tesselation/CandidateForTesselation.hpp \
   Tesselation/ellipsoid.hpp \
-  IPointCloud.hpp \
-  PointCloudAdaptor.hpp \
   Tesselation/tesselation.hpp \
   Tesselation/tesselationhelpers.hpp \
@@ -169,4 +175,5 @@
   ${DESCRIPTORSOURCE} \
   ${DYNAMICSSOURCE} \
+  ${LINKEDCELLSOURCE} \
   ${THERMOSTATSOURCE} \
   ${TESSELATIONSOURCE} \
@@ -174,5 +181,4 @@
   config.cpp \
   Formula.cpp \
-  linkedcell.cpp \
   MoleculeLeafClass.cpp \
   moleculelist.cpp \
@@ -191,4 +197,5 @@
   ${DESCRIPTORIMPLHEADER} \
   ${DYNAMICSHEADER} \
+  ${LINKEDCELLHEADER} \
   ${THERMOSTATHEADER} \
   ${TESSELATIONHEADER} \
@@ -198,5 +205,4 @@
   IdPool.hpp \
   IdPool_impl.hpp \
-  linkedcell.hpp \
   MoleculeLeafClass.hpp \
   MoleculeListClass.hpp \
Index: c/PointCloudAdaptor.hpp
===================================================================
--- src/PointCloudAdaptor.hpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ 	(revision )
@@ -1,98 +1,0 @@
-/*
- * PointCloudAdaptor.hpp
- *
- *  Created on: Feb 21, 2011
- *      Author: heber
- */
-
-#ifndef POINTCLOUDADAPTOR_HPP_
-#define POINTCLOUDADAPTOR_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "CodePatterns/Assert.hpp"
-#include "IPointCloud.hpp"
-#include "Tesselation/TesselPoint.hpp"
-#include "LinearAlgebra/Vector.hpp"
-
-/** Adaptor class to IPointCloud, specialized for all needed classes.
- */
-template <class container_type,
-          class iterator_type = typename container_type::iterator>
-class PointCloudAdaptor: public IPointCloud
-{
-public:
-  PointCloudAdaptor(container_type *_list, const std::string _name) :
-    list(_list),
-    name(_name)
-  {}
-  virtual ~PointCloudAdaptor()
-  {
-    list = NULL;
-  }
-
-  const std::string& GetName() const
-  {
-    return name;
-  }
-  Vector *GetCenter() const
-  {
-    Vector *Center = new Vector(0., 0., 0.);
-    int num = 0;
-    for (iterator_type iter = iterator_type(list->begin());
-        iter != iterator_type(list->end());
-        ++iter) {
-      (*Center) += ((*iter)->getPosition());
-      num++;
-    }
-    Center->Scale(1. / num);
-    return Center;
-  }
-
-  TesselPoint *GetPoint()
-  {
-    ASSERT(!IsEnd(), "PointCloudAdaptor<T>::getPoint() - invalid InternalIterator.");
-    return (*InternalIterator)->getTesselPoint();
-  }
-  int GetMaxId() const
-  {
-    int maxid = -1;
-    for (iterator_type iter = iterator_type(list->begin());
-        iter != iterator_type(list->end());
-        ++iter) {
-      if ((maxid == -1) || ((*iter)->getNr() > maxid)) {
-        maxid = (*iter)->getNr();
-      }
-    }
-    return maxid;
-  }
-  void GoToNext()
-  {
-    if (InternalIterator != iterator_type(list->end()))
-      ++InternalIterator;
-  }
-  void GoToFirst()
-  {
-    InternalIterator = iterator_type(list->begin());
-  }
-  bool IsEmpty() const
-  {
-    return list->begin() == list->end();
-  }
-  bool IsEnd() const
-  {
-    return InternalIterator == iterator_type(list->end());
-  }
-
-private:
-  container_type *list;
-  iterator_type InternalIterator;
-  const std::string name;
-};
-
-
-
-#endif /* POINTCLOUDADAPTOR_HPP_ */
Index: src/Tesselation/CandidateForTesselation.cpp
===================================================================
--- src/Tesselation/CandidateForTesselation.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/CandidateForTesselation.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -31,10 +31,7 @@
 #include "CodePatterns/Assert.hpp"
 #include "CodePatterns/Info.hpp"
-//#include "Line.hpp"
-#include "linkedcell.hpp"
 #include "CodePatterns/Log.hpp"
-//#include "Plane.hpp"
 #include "LinearAlgebra/Vector.hpp"
-#include "CodePatterns/Verbose.hpp"
+#include "LinkedCell/linkedcell.hpp"
 
 using namespace std;
Index: src/Tesselation/boundary.cpp
===================================================================
--- src/Tesselation/boundary.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/boundary.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -33,8 +33,8 @@
 #include "LinearAlgebra/Plane.hpp"
 #include "LinearAlgebra/RealSpaceMatrix.hpp"
-#include "linkedcell.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "molecule.hpp"
 #include "MoleculeListClass.hpp"
-#include "PointCloudAdaptor.hpp"
 #include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
 #include "RandomNumbers/RandomNumberGenerator.hpp"
Index: src/Tesselation/ellipsoid.cpp
===================================================================
--- src/Tesselation/ellipsoid.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/ellipsoid.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -27,13 +27,12 @@
 #include <set>
 
+#include "CodePatterns/Log.hpp"
+#include "ellipsoid.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "LinearAlgebra/RealSpaceMatrix.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "Tesselation/BoundaryPointSet.hpp"
 #include "Tesselation/boundary.hpp"
-#include "ellipsoid.hpp"
-#include "linkedcell.hpp"
-#include "CodePatterns/Log.hpp"
-#include "tesselation.hpp"
-#include "LinearAlgebra/Vector.hpp"
-#include "LinearAlgebra/RealSpaceMatrix.hpp"
-#include "CodePatterns/Verbose.hpp"
+#include "Tesselation/tesselation.hpp"
 
 #include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
Index: src/Tesselation/tesselation.cpp
===================================================================
--- src/Tesselation/tesselation.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/tesselation.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -23,4 +23,6 @@
 #include <iomanip>
 #include <sstream>
+
+#include "tesselation.hpp"
 
 #include "BoundaryPointSet.hpp"
@@ -35,5 +37,4 @@
 #include "CodePatterns/Verbose.hpp"
 #include "Helpers/helpers.hpp"
-#include "IPointCloud.hpp"
 #include "LinearAlgebra/Exceptions.hpp"
 #include "LinearAlgebra/Line.hpp"
@@ -41,7 +42,7 @@
 #include "LinearAlgebra/Vector.hpp"
 #include "LinearAlgebra/vector_ops.hpp"
-#include "linkedcell.hpp"
-#include "PointCloudAdaptor.hpp"
-#include "tesselation.hpp"
+#include "LinkedCell/IPointCloud.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "tesselationhelpers.hpp"
 #include "TesselPoint.hpp"
Index: src/Tesselation/tesselationhelpers.cpp
===================================================================
--- src/Tesselation/tesselationhelpers.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/tesselationhelpers.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -21,4 +21,6 @@
 
 #include <fstream>
+
+#include "tesselationhelpers.hpp"
 
 #include "BoundaryLineSet.hpp"
@@ -30,5 +32,4 @@
 #include "CodePatterns/Log.hpp"
 #include "CodePatterns/Verbose.hpp"
-#include "IPointCloud.hpp"
 #include "LinearAlgebra/Line.hpp"
 #include "LinearAlgebra/LinearSystemOfEquations.hpp"
@@ -37,7 +38,7 @@
 #include "LinearAlgebra/Vector.hpp"
 #include "LinearAlgebra/vector_ops.hpp"
-#include "linkedcell.hpp"
+#include "LinkedCell/IPointCloud.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "tesselation.hpp"
-#include "tesselationhelpers.hpp"
 
 void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
Index: src/Tesselation/unittests/TesselationUnitTest.cpp
===================================================================
--- src/Tesselation/unittests/TesselationUnitTest.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/unittests/TesselationUnitTest.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -26,10 +26,10 @@
 #include <cstring>
 
+#include "CodePatterns/Log.hpp"
+#include "Helpers/defs.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "Tesselation/BoundaryLineSet.hpp"
 #include "Tesselation/BoundaryTriangleSet.hpp"
 #include "Tesselation/CandidateForTesselation.hpp"
-#include "CodePatterns/Log.hpp"
-#include "Helpers/defs.hpp"
-#include "PointCloudAdaptor.hpp"
 #include "Tesselation/TesselPoint.hpp"
 
Index: src/Tesselation/unittests/TesselationUnitTest.hpp
===================================================================
--- src/Tesselation/unittests/TesselationUnitTest.hpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/unittests/TesselationUnitTest.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -19,5 +19,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "linkedcell.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "Tesselation/tesselation.hpp"
 
Index: src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp
===================================================================
--- src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -19,5 +19,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "linkedcell.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "Tesselation/tesselation.hpp"
 
Index: src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp
===================================================================
--- src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -27,11 +27,11 @@
 #include <iostream>
 
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Helpers/defs.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "Tesselation/BoundaryLineSet.hpp"
 #include "Tesselation/BoundaryTriangleSet.hpp"
 #include "Tesselation/CandidateForTesselation.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "Helpers/defs.hpp"
-#include "PointCloudAdaptor.hpp"
 #include "Tesselation/TesselPoint.hpp"
 
Index: src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp
===================================================================
--- src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -19,5 +19,5 @@
 #include <cppunit/extensions/HelperMacros.h>
 
-#include "linkedcell.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "Tesselation/tesselation.hpp"
 
Index: c/linkedcell.cpp
===================================================================
--- src/linkedcell.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ 	(revision )
@@ -1,357 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2010-2011 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/** \file linkedcell.cpp
- *
- * Function implementations for the class LinkedCell.
- *
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include "atom.hpp"
-#include "linkedcell.hpp"
-#include "CodePatterns/Verbose.hpp"
-#include "CodePatterns/Range.hpp"
-#include "CodePatterns/Log.hpp"
-#include "molecule.hpp"
-#include "IPointCloud.hpp"
-#include "Tesselation/tesselation.hpp"
-#include "LinearAlgebra/Vector.hpp"
-
-// ========================================================= class LinkedCell ===========================================
-
-/** Constructor for class LinkedCell.
- */
-LinkedCell::LinkedCell() :
-  LC(NULL),
-  RADIUS(0.),
-  index(-1)
-{
-  for(int i=0;i<NDIM;i++)
-    N[i] = 0;
-  max.Zero();
-  min.Zero();
-};
-
-/** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS
- * \param *set LCNodeSet class with all LCNode's
- * \param RADIUS edge length of cells
- */
-LinkedCell::LinkedCell(IPointCloud & set, const double radius) :
-  LC(NULL),
-  RADIUS(radius),
-  index(-1)
-{
-  TesselPoint *Walker = NULL;
-
-  for(int i=0;i<NDIM;i++)
-    N[i] = 0;
-  max.Zero();
-  min.Zero();
-  LOG(1, "Begin of LinkedCell");
-  if (set.IsEmpty()) {
-    ELOG(1, "set is NULL or contains no linked cell nodes!");
-    return;
-  }
-  // 1. find max and min per axis of atoms
-  set.GoToFirst();
-  Walker = set.GetPoint();
-  for (int i=0;i<NDIM;i++) {
-    max[i] = Walker->at(i);
-    min[i] = Walker->at(i);
-  }
-  set.GoToFirst();
-  while (!set.IsEnd()) {
-    Walker = set.GetPoint();
-    for (int i=0;i<NDIM;i++) {
-      if (max[i] < Walker->at(i))
-        max[i] = Walker->at(i);
-      if (min[i] > Walker->at(i))
-        min[i] = Walker->at(i);
-    }
-    set.GoToNext();
-  }
-  LOG(2, "Bounding box is " << min << " and " << max << ".");
-
-  // 2. find then number of cells per axis
-  for (int i=0;i<NDIM;i++) {
-    N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);
-  }
-  LOG(2, "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << ".");
-
-  // 3. allocate the lists
-  LOG(2, "INFO: Allocating cells ... ");
-  if (LC != NULL) {
-    ELOG(1, "Linked Cell list is already allocated, I do nothing.");
-    return;
-  }
-  ASSERT(N[0]*N[1]*N[2] < MAX_LINKEDCELLNODES, "Number linked of linked cell nodes exceded hard-coded limit, use greater edge length!");
-  LC = new TesselPointSTLList[N[0]*N[1]*N[2]];
-  for (index=0;index<N[0]*N[1]*N[2];index++) {
-    LC [index].clear();
-  }
-  LOG(0, "done.");
-
-  // 4. put each atom into its respective cell
-  LOG(2, "INFO: Filling cells ... ");
-  set.GoToFirst();
-  while (!set.IsEnd()) {
-    Walker = set.GetPoint();
-    for (int i=0;i<NDIM;i++) {
-      n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
-    }
-    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
-    LC[index].push_back(Walker);
-    //LOG(2, *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << ".");
-    set.GoToNext();
-  }
-  LOG(0, "done.");
-  LOG(1, "End of LinkedCell");
-};
-
-
-/** Destructor for class LinkedCell.
- */
-LinkedCell::~LinkedCell()
-{
-  if (LC != NULL)
-  for (index=0;index<N[0]*N[1]*N[2];index++)
-    LC[index].clear();
-  delete[](LC);
-  for(int i=0;i<NDIM;i++)
-    N[i] = 0;
-  index = -1;
-};
-
-/** Checks whether LinkedCell::n[] is each within [0,N[]].
- * \return if all in intervals - true, else -false
- */
-bool LinkedCell::CheckBounds() const
-{
-  bool status = true;
-  for(int i=0;i<NDIM;i++)
-    status = status && ((n[i] >=0) && (n[i] < N[i]));
-//  if (!status)
-//    ELOG(1, "indices are out of bounds!");
-  return status;
-};
-
-/** Checks whether LinkedCell::n[] plus relative offset is each within [0,N[]].
- * Note that for this check we don't admonish if out of bounds.
- * \param relative[NDIM] relative offset to current cell
- * \return if all in intervals - true, else -false
- */
-bool LinkedCell::CheckBounds(const int relative[NDIM]) const
-{
-  bool status = true;
-  for(int i=0;i<NDIM;i++)
-    status = status && ((n[i]+relative[i] >=0) && (n[i]+relative[i] < N[i]));
-  return status;
-};
-
-
-/** Returns a pointer to the current cell.
- * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds.
- */
-const TesselPointSTLList* LinkedCell::GetCurrentCell() const
-{
-  if (CheckBounds()) {
-    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
-    return (&(LC[index]));
-  } else {
-    return NULL;
-  }
-};
-
-/** Returns a pointer to the current cell.
- * \param relative[NDIM] offset for each axis with respect to the current cell LinkedCell::n[NDIM]
- * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds.
- */
-const TesselPointSTLList* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
-{
-  if (CheckBounds(relative)) {
-    index = (n[0]+relative[0]) * N[1] * N[2] + (n[1]+relative[1]) * N[2] + (n[2]+relative[2]);
-    return (&(LC[index]));
-  } else {
-    return NULL;
-  }
-};
-
-/** Set the index to the cell containing a given Vector *x.
- * \param *x Vector with coordinates
- * \return Vector is inside bounding box - true, else - false
- */
-bool LinkedCell::SetIndexToVector(const Vector & x) const
-{
-  for (int i=0;i<NDIM;i++)
-    n[i] = (int)floor((x.at(i) - min[i])/RADIUS);
-
-  return CheckBounds();
-};
-
-/** Calculates the index for a given LCNode *Walker.
- * \param *Walker LCNode to set index tos
- * \return if the atom is also found in this cell - true, else - false
- */
-bool LinkedCell::SetIndexToNode(const TesselPoint * const Walker) const
-{
-  bool status = false;
-  for (int i=0;i<NDIM;i++) {
-    n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));
-  }
-  index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
-  if (CheckBounds()) {
-    for (TesselPointSTLList::iterator Runner = LC[index].begin(); Runner != LC[index].end(); Runner++)
-      status = status || ((*Runner) == Walker);
-    return status;
-  } else {
-    ELOG(1, "Node at " << *Walker << " is out of bounds.");
-    return false;
-  }
-};
-
-/** Calculates the interval bounds of the linked cell grid.
- * \param lower lower bounds
- * \param upper upper bounds
- * \param step how deep to check the neighbouring cells (i.e. number of layers to check)
- */
-void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step) const
-{
-  for (int i=0;i<NDIM;i++) {
-    lower[i] = n[i]-step;
-    if (lower[i] < 0)
-      lower[i] = 0;
-    if (lower[i] >= N[i])
-      lower[i] = N[i]-1;
-    upper[i] = n[i]+step;
-    if (upper[i] >= N[i])
-      upper[i] = N[i]-1;
-    if (upper[i] < 0)
-      upper[i] = 0;
-    //LOG(0, "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]");
-  }
-};
-
-/** Returns a list with all neighbours from the current LinkedCell::index.
- * \param distance (if no distance, then adjacent cells are taken)
- * \return list of tesselpoints
- */
-TesselPointSTLList* LinkedCell::GetallNeighbours(const double distance) const
-{
-  int Nlower[NDIM], Nupper[NDIM];
-  TesselPoint *Walker = NULL;
-  TesselPointSTLList *TesselList = new TesselPointSTLList;
-
-  // then go through the current and all neighbouring cells and check the contained points for possible candidates
-  const int step = (distance == 0) ? 1 : (int)floor(distance/RADIUS + 1.);
-  GetNeighbourBounds(Nlower, Nupper, step);
-
-  for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++)
-    for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++)
-      for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) {
-        const TesselPointSTLList *List = GetCurrentCell();
-        //LOG(1, "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << ".");
-        if (List != NULL) {
-          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
-            Walker = *Runner;
-            TesselList->push_back(Walker);
-          }
-        }
-      }
-  return TesselList;
-};
-
-/** Set the index to the cell containing a given Vector *x, which is not inside the LinkedCell's domain
- * Note that as we have to check distance from every corner of the closest cell, this function is faw more
- * expensive and if Vector is known to be inside LinkedCell's domain, then SetIndexToVector() should be used.
- * \param *x Vector with coordinates
- * \return minimum squared distance of cell to given vector (if inside of domain, distance is 0)
- */
-double LinkedCell::SetClosestIndexToOutsideVector(const Vector * const x) const
-{
-  for (int i=0;i<NDIM;i++) {
-    n[i] = (int)floor((x->at(i) - min[i])/RADIUS);
-    if (n[i] < 0)
-      n[i] = 0;
-    if (n[i] >= N[i])
-      n[i] = N[i]-1;
-  }
-
-  // calculate distance of cell to vector
-  double distanceSquared = 0.;
-  bool outside = true;  // flag whether x is found in- or outside of LinkedCell's domain/closest cell
-  Vector corner; // current corner of closest cell
-  Vector tester; // Vector pointing from corner to center of closest cell
-  Vector Distance;  // Vector from corner of closest cell to x
-
-  Vector center;  // center of the closest cell
-  for (int i=0;i<NDIM;i++)
-    center[i] = min[i]+((double)n[i]+.5)*RADIUS;
-
-  int c[NDIM];
-  for (c[0]=0;c[0]<=1;c[0]++)
-    for (c[1]=0; c[1]<=1;c[1]++)
-      for (c[2]=0; c[2]<=1;c[2]++) {
-        // set up corner
-        for (int i=0;i<NDIM;i++)
-          corner[i] = min[i]+RADIUS*((double)n[i]+c[i]);
-        // set up distance vector
-        Distance = (*x) - corner;
-        const double dist = Distance.NormSquared();
-        // check whether distance is smaller
-        if (dist< distanceSquared)
-          distanceSquared = dist;
-        // check whether distance vector goes inside or outside
-        tester = center -corner;
-        if (tester.ScalarProduct(Distance) < 0)
-          outside = false;
-      }
-  return (outside ? distanceSquared : 0.);
-};
-
-/** Returns a list of all TesselPoint with distance less than \a radius to \a *Center.
- * \param radius radius of sphere
- * \param *center center of sphere
- * \return list of all points inside sphere
- */
-TesselPointSTLList* LinkedCell::GetPointsInsideSphere(const double radius, const Vector * const center) const
-{
-  const double radiusSquared = radius*radius;
-  TesselPoint *Walker = NULL;
-  TesselPointSTLList *TesselList = new TesselPointSTLList;
-  TesselPointSTLList *NeighbourList = NULL;
-
-  // set index of LC to center of sphere
-  const double dist = SetClosestIndexToOutsideVector(center);
-  if (dist > 2.*radius) {
-    ELOG(1, "Vector " << *center << " is too far away from any atom in LinkedCell's bounding box.");
-    return TesselList;
-  } else
-    LOG(1, "Distance of closest cell to center of sphere with radius " << radius << " is " << dist << ".");
-
-  // gather all neighbours first, then look who fulfills distance criteria
-  NeighbourList = GetallNeighbours(2.*radius-dist);
-  //LOG(1, "I found " << NeighbourList->size() << " neighbours to check.");
-  if (NeighbourList != NULL) {
-    for (TesselPointSTLList::const_iterator Runner = NeighbourList->begin(); Runner != NeighbourList->end(); Runner++) {
-      Walker = *Runner;
-      //LOG(1, "Current neighbour is at " << *Walker->node << ".");
-      if ((Walker->DistanceSquared(*center) - radiusSquared) < MYEPSILON) {
-        TesselList->push_back(Walker);
-      }
-    }
-    delete(NeighbourList);
-  } else
-    ELOG(2, "Around vector " << *center << " there are no atoms.");
-  return TesselList;
-};
Index: c/linkedcell.hpp
===================================================================
--- src/linkedcell.hpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ 	(revision )
@@ -1,82 +1,0 @@
-/*
- * linkedcell.hpp
- *
- *  If the linked cell should be usable, the class has to inherit LCNodeSet and the nodes (containing the Vectors) have to inherit LCNode. This works well
- *  for molecule and atom classes.
- *
- *  Created on: Aug 3, 2009
- *      Author: heber
- */
-
-#ifndef LINKEDCELL_HPP_
-#define LINKEDCELL_HPP_
-
-using namespace std;
-
-/*********************************************** includes ***********************************/
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <list>
-#include <vector>
-#include <map>
-
-//#include "CodePatterns/Assert.hpp"
-//#include "CodePatterns/Log.hpp"
-//#include "CodePatterns/Verbose.hpp"
-#include "Helpers/defs.hpp"
-#include "LinearAlgebra/Vector.hpp"
-#include "World.hpp"
-
-/****************************************** forward declarations *****************************/
-
-class IPointCloud;
-class TesselPoint;
-
-/********************************************** definitions *********************************/
-
-//< Upper bound for number of cell nodes used in sensibility check on allocation.
-enum { MAX_LINKEDCELLNODES = 1000000 };
-
-/********************************************** declarations *******************************/
-
-typedef std::list<TesselPoint *> TesselPointSTLList;
-
-/** Linked Cell class for containing Vectors in real space efficiently.
- */
-class LinkedCell {
-private:
-
-public:
-    Vector max;       // upper boundary
-    Vector min;       // lower boundary
-    TesselPointSTLList *LC;  // linked cell list
-    double RADIUS;    // cell edge length
-    int N[NDIM];      // number of cells per axis
-    mutable int n[NDIM];      // temporary variable for current cell per axis
-    mutable int index;        // temporary index variable , access by index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
-
-    LinkedCell();
-    LinkedCell(IPointCloud &set, const double radius);
-    ~LinkedCell();
-    const TesselPointSTLList* GetCurrentCell()const ;
-    const TesselPointSTLList* GetRelativeToCurrentCell(const int relative[NDIM])const ;
-    bool SetIndexToNode(const TesselPoint * const Walker)const ;
-    bool SetIndexToVector(const Vector &x)const ;
-    double SetClosestIndexToOutsideVector(const Vector * const x) const;
-    bool CheckBounds()const ;
-    bool CheckBounds(const int relative[NDIM])const ;
-    void GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step = 1)const ;
-
-    TesselPointSTLList* GetallNeighbours(const double distance = 0) const;
-    TesselPointSTLList* GetPointsInsideSphere(const double radius, const Vector * const center) const;
-    // not implemented yet
-    bool AddNode(Vector *Walker);
-    bool DeleteNode(Vector *Walker);
-    bool MoveNode(Vector *Walker);
-};
-
-#endif /*LINKEDCELL_HPP_*/
Index: src/molecule.cpp
===================================================================
--- src/molecule.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/molecule.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -33,4 +33,5 @@
 #include "config.hpp"
 #include "Element/element.hpp"
+#include "Element/periodentafel.hpp"
 #include "Graph/BondGraph.hpp"
 #include "LinearAlgebra/Exceptions.hpp"
@@ -39,7 +40,6 @@
 #include "LinearAlgebra/RealSpaceMatrix.hpp"
 #include "LinearAlgebra/Vector.hpp"
-#include "linkedcell.hpp"
+#include "LinkedCell/linkedcell.hpp"
 #include "molecule.hpp"
-#include "Element/periodentafel.hpp"
 #include "Tesselation/tesselation.hpp"
 #include "World.hpp"
Index: src/molecule_graph.cpp
===================================================================
--- src/molecule_graph.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/molecule_graph.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -36,7 +36,7 @@
 #include "Helpers/helpers.hpp"
 #include "LinearAlgebra/RealSpaceMatrix.hpp"
-#include "linkedcell.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "molecule.hpp"
-#include "PointCloudAdaptor.hpp"
 #include "World.hpp"
 #include "WorldTime.hpp"
Index: src/unittests/LinkedCellUnitTest.cpp
===================================================================
--- src/unittests/LinkedCellUnitTest.cpp	(revision 3e4fb6fae7d3dcc8e46ee174d7b9a70a995ac178)
+++ src/unittests/LinkedCellUnitTest.cpp	(revision 53c7fc2e5e8198eaf2ef2d962e2e7c72910e48ae)
@@ -32,8 +32,8 @@
 #include "Descriptors/MoleculeDescriptor.hpp"
 #include "Element/element.hpp"
-#include "linkedcell.hpp"
+#include "Element/periodentafel.hpp"
+#include "LinkedCell/linkedcell.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
 #include "molecule.hpp"
-#include "Element/periodentafel.hpp"
-#include "PointCloudAdaptor.hpp"
 #include "World.hpp"
 
