Index: src/tesselation.cpp
===================================================================
--- src/tesselation.cpp	(revision f67b6e18b0b9f6a29d0dcad5ca54afbf56ac58e2)
+++ src/tesselation.cpp	(revision 7273fcd1e27e7a9eff3252574c0b87a515886042)
@@ -1657,8 +1657,8 @@
 	Info FunctionInfo(__func__);
   int i = 0;
-  TesselPoint* FirstPoint = NULL;
-  TesselPoint* SecondPoint = NULL;
   TesselPoint* MaxPoint[NDIM];
+  TesselPoint* Temporary;
   double maxCoordinate[NDIM];
+  BoundaryLineSet BaseLine;
   Vector Oben;
   Vector helper;
@@ -1703,18 +1703,17 @@
     Oben.Zero();
     Oben.x[k] = 1.;
-    FirstPoint = MaxPoint[k];
-    Log() << Verbose(0) << "Coordinates of start node at " << *FirstPoint->node << "." << endl;
+    BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]);
+    Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
 
     double ShortestAngle;
-    TesselPoint* OptCandidate = NULL;
     ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
 
-    FindSecondPointForTesselation(FirstPoint, Oben, OptCandidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
-    SecondPoint = OptCandidate;
-    if (SecondPoint == NULL)  // have we found a second point?
+    FindSecondPointForTesselation(BaseLine.endpoints[0]->node, Oben, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
+    if (Temporary == NULL)  // have we found a second point?
       continue;
-
-    helper.CopyVector(FirstPoint->node);
-    helper.SubtractVector(SecondPoint->node);
+    BaseLine.endpoints[1] = new BoundaryPointSet(Temporary);
+
+    helper.CopyVector(BaseLine.endpoints[0]->node->node);
+    helper.SubtractVector(BaseLine.endpoints[1]->node->node);
     helper.Normalize();
     Oben.ProjectOntoPlane(&helper);
@@ -1723,6 +1722,6 @@
     ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
 
-    Chord.CopyVector(FirstPoint->node); // bring into calling function
-    Chord.SubtractVector(SecondPoint->node);
+    Chord.CopyVector(BaseLine.endpoints[0]->node->node); // bring into calling function
+    Chord.SubtractVector(BaseLine.endpoints[1]->node->node);
     double radius = Chord.ScalarProduct(&Chord);
     double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
@@ -1735,12 +1734,9 @@
 
     // adding point 1 and point 2 and add the line between them
-    Log() << Verbose(0) << "Coordinates of start node at " << *FirstPoint->node << "." << endl;
-    AddTesselationPoint(FirstPoint, 0);
-    Log() << Verbose(0) << "Found second point is at " << *SecondPoint->node << ".\n";
-    AddTesselationPoint(SecondPoint, 1);
-    AddTesselationLine(TPS[0], TPS[1], 0);
+    Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
+    Log() << Verbose(0) << "Found second point is at " << *BaseLine.endpoints[1]->node << ".\n";
 
     //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n";
-    CandidateForTesselation OptCandidates(BLS[0]);
+    CandidateForTesselation OptCandidates(&BaseLine);
     FindThirdPointForTesselation(Oben, SearchDirection, helper, OptCandidates, NULL, RADIUS, LC);
     Log() << Verbose(0) << "List of third Points is:" << endl;
@@ -1749,36 +1745,14 @@
     }
 
-    for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) {
-      // add third triangle point
-      AddTesselationPoint((*it), 2);
-      // add the second and third line
-      AddTesselationLine(TPS[1], TPS[2], 1);
-      AddTesselationLine(TPS[0], TPS[2], 2);
-      // ... and triangles to the Maps of the Tesselation class
-      BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
-      AddTesselationTriangle();
-      // ... and calculate its normal vector (with correct orientation)
-      OptCandidates.OptCenter.Scale(-1.);
-      Log() << Verbose(1) << "Anti-Oben is currently " << OptCandidates.OptCenter << "." << endl;
-      BTS->GetNormalVector(OptCandidates.OptCenter);  // vector to compare with should point inwards
-      OptCandidates.OptCenter.Scale(-1.);
-      Log() << Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and "
-      << (*it) << " with normal vector " << BTS->NormalVector << ".\n";
-
-//      // if we do not reach the end with the next step of iteration, we need to setup a new first line
-//      if (it != OptCandidates->end()--) {
-//        FirstPoint = (*it)->BaseLine->endpoints[0]->node;
-//        SecondPoint = (*it)->point;
-//        // adding point 1 and point 2 and the line between them
-//        AddTesselationPoint(FirstPoint, 0);
-//        AddTesselationPoint(SecondPoint, 1);
-//        AddTesselationLine(TPS[0], TPS[1], 0);
-//      }
-      Log() << Verbose(1) << "Projection is " << BTS->NormalVector.ScalarProduct(&Oben) << "." << endl;
-    }
+    BTS = NULL;
+    AddCandidateTriangle(OptCandidates);
+//    delete(BaseLine.endpoints[0]);
+//    delete(BaseLine.endpoints[1]);
+
     if (BTS != NULL) // we have created one starting triangle
       break;
     else {
       // remove all candidates from the list and then the list itself
+      OptCandidates.pointlist.clear();
     }
   }
@@ -2107,13 +2081,13 @@
     Log() << Verbose(2) << "BaseLine is :" << *(BaseLine) << " with current candidate " << *(*Runner) << "." << endl;
     // add the points
-    AddTesselationPoint((*Runner), 0);
-    AddTesselationPoint(BaseLine->endpoints[0]->node, 1);
-    AddTesselationPoint(BaseLine->endpoints[1]->node, 2);
+    AddTesselationPoint(BaseLine->endpoints[0]->node, 0);
+    AddTesselationPoint(BaseLine->endpoints[1]->node, 1);
+    AddTesselationPoint((*Runner), 2);
 
     Center.CopyVector(&CandidateLine.OptCenter);
     // add the lines
-    AddTesselationLine(TPS[0], TPS[1], 0);
-    AddTesselationLine(TPS[0], TPS[2], 1);
-    AddTesselationLine(TPS[1], TPS[2], 2);
+    AddTesselationLine(TPS[2], TPS[0], 0);
+    AddTesselationLine(TPS[2], TPS[1], 1);
+    AddTesselationLine(TPS[0], TPS[1], 2);
 
     // add the triangles
