Index: src/boundary.cpp
===================================================================
--- src/boundary.cpp	(revision 7c6712a25ea23cdfa7e88b8f2293af4c65278eec)
+++ src/boundary.cpp	(revision 44fd957c290401f17701bb788d3d339733fe6b38)
@@ -2,5 +2,5 @@
 #include "boundary.hpp"
 
-#define DEBUG 0
+#define DEBUG 1
 
 // ======================================== Points on Boundary =================================
@@ -1435,8 +1435,9 @@
     Vector TempNormal, helper;
     double Restradius;
-
+    cout << Verbose(3) << "Begin of Get_center_of_sphere.\n";
     *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ;
     Center->Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma)));
     // Here we calculated center of circumscribing circle, using barycentric coordinates
+    cout << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
 
     TempNormal.CopyVector(&a);
@@ -1452,7 +1453,11 @@
     TempNormal.Normalize();
     Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
+    cout << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";
     TempNormal.Scale(Restradius);
+    cout << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
 
     Center->AddVector(&TempNormal);
+    cout << Verbose(4) << "Center of sphere of circumference is " << *Center << ".\n";
+    cout << Verbose(3) << "End of Get_center_of_sphere.\n";
   }
   ;
@@ -1486,7 +1491,10 @@
     atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol)
 {
-
-  cout << Verbose(1) << "Candidate is "<< Candidate->nr << endl;
-  cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl;
+  cout << Verbose(2) << "Begin of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n";
+  cout << Verbose(3) << "Candidate is "<< *Candidate << endl;
+  cout << Verbose(4) << "Baseline vector is " << *Chord << "." << endl;
+  cout << Verbose(4) << "ReferencePoint is " << ReferencePoint << "." << endl;
+  cout << Verbose(4) << "Normal of base triangle is " << *OldNormal << "." << endl;
+  cout << Verbose(4) << "Search direction is " << *direction1 << "." << endl;
   /* OldNormal is normal vector on the old triangle
    * direction1 is normal on the triangle line, from which we come, as well as on OldNormal.
@@ -1505,23 +1513,28 @@
 
 
-  dif_a.CopyVector(&(a->x));
-  dif_a.SubtractVector(&(Candidate->x));
-  dif_b.CopyVector(&(b->x));
-  dif_b.SubtractVector(&(Candidate->x));
-  AngleCheck.CopyVector(&(Candidate->x));
-  AngleCheck.SubtractVector(&(a->x));
-  AngleCheck.ProjectOntoPlane(Chord);
-
-  SideA = dif_b.Norm();
-  SideB = dif_a.Norm();
-  SideC = Chord->Norm();
-  //Chord->Scale(-1);
-
-  alpha = Chord->Angle(&dif_a);
-  beta = M_PI - Chord->Angle(&dif_b);
-  gamma = dif_a.Angle(&dif_b);
-
   if (a != Candidate and b != Candidate)
     {
+      cout << Verbose(3) << "We have a unique candidate!" << endl;
+      dif_a.CopyVector(&(a->x));
+      dif_a.SubtractVector(&(Candidate->x));
+      dif_b.CopyVector(&(b->x));
+      dif_b.SubtractVector(&(Candidate->x));
+      AngleCheck.CopyVector(&(Candidate->x));
+      AngleCheck.SubtractVector(&(a->x));
+      AngleCheck.ProjectOntoPlane(Chord);
+
+      SideA = dif_b.Norm();
+      SideB = dif_a.Norm();
+      SideC = Chord->Norm();
+      //Chord->Scale(-1);
+
+      alpha = Chord->Angle(&dif_a);
+      beta = M_PI - Chord->Angle(&dif_b);
+      gamma = dif_a.Angle(&dif_b);
+
+      cout << Verbose(2) << "Base triangle has sides " << dif_a << ", " << dif_b << ", " << *Chord << " with angles " << alpha/M_PI*180. << ", " << beta/M_PI*180. << ", " << gamma/M_PI*180. << "." << endl;
+
+      if (fabs(M_PI - alpha - beta - gamma) > MYEPSILON)
+        cerr << Verbose(0) << "WARNING: sum of angles for candidate triangle " << (alpha + beta + gamma)/M_PI*180. << " != 180.\n";
 
       Umkreisradius = SideA / 2.0 / sin(alpha);
@@ -1532,35 +1545,43 @@
       if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points.
         {
+          cout << Verbose(3) << "Circle of circumference would fit: " << Umkreisradius << " < " << RADIUS << "." << endl;
           sign = AngleCheck.ScalarProduct(direction1);
-          sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
-
-          Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, sign, alpha, beta, gamma, RADIUS, Umkreisradius);
-
-          AngleCheck.CopyVector(&ReferencePoint);
-          AngleCheck.Scale(-1);
-          cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
-          AngleCheck.AddVector(&Mittelpunkt);
-          cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
-
-          BallAngle = AngleCheck.Angle(OldNormal);
-          cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl;
-          cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
-          sign = AngleCheck.ScalarProduct(direction1);
-          sign /= fabs(sign);
-
-
-          if (sign >0)
+          if (fabs(sign) < MYEPSILON)
+            sign = 0;
+          else
+            sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
+          if (sign >= 0)
             {
+            cout << Verbose(3) << "Candidate is in search direction: " << sign << "." << endl;
+
+            Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, sign, alpha, beta, gamma, RADIUS, Umkreisradius);
+
+            AngleCheck.CopyVector(&ReferencePoint);
+            AngleCheck.Scale(-1);
+            //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
+            AngleCheck.AddVector(&Mittelpunkt);
+            //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
+            cout << Verbose(4) << "Reference vector to sphere's center is " << AngleCheck << "." << endl;
+
+            BallAngle = AngleCheck.Angle(OldNormal);
+            cout << Verbose(3) << "Angle between normal of base triangle and center of ball sphere is :" << BallAngle << "." << endl;
+  //          cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl;
+  //          cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
+            sign = AngleCheck.ScalarProduct(direction1);
+            if (fabs(sign) < MYEPSILON)
+              sign = 0;
+            else
+              sign /= fabs(sign);
+
+
               if (Storage[0]< -1.5) // first Candidate at all
                 {
 
-                  cout << "Next better candidate is " << *Candidate << " with ";
+                  cout << Verbose(2) << "First good candidate is " << *Candidate << " with ";
                   Opt_Candidate = Candidate;
                   Storage[0] = sign;
                   Storage[1] = BallAngle;
-                  cout << "Angle is " << Storage[1] << ", Halbraum ist "
+                  cout << " angle " << Storage[1] << " and Up/Down "
                     << Storage[0] << endl;
-
-
                 }
               else
@@ -1568,9 +1589,9 @@
                   if ( Storage[1] > BallAngle)
                     {
-                      cout << "Next better candidate is " << *Candidate << " with ";
+                      cout << Verbose(2) << "Next better candidate is " << *Candidate << " with ";
                       Opt_Candidate = Candidate;
                       Storage[0] = sign;
                       Storage[1] = BallAngle;
-                      cout << "Angle is " << Storage[1] << ", Halbraum ist "
+                      cout << " angle " << Storage[1] << " and Up/Down "
                         << Storage[0] << endl;
                     }
@@ -1579,5 +1600,5 @@
                       if (DEBUG)
                         {
-                          cout << "Looses to better candidate" << endl;
+                          cout << Verbose(3) << *Candidate << " looses against better candidate " << *Opt_Candidate << "." << endl;
                         }
                     }
@@ -1586,5 +1607,8 @@
             else
               {
-                cout << "Refused due to sign which is " << sign << endl;
+              if (DEBUG)
+                {
+                  cout << Verbose(3) << *Candidate << " refused due to Up/Down sign which is " << sign << endl;
+                }
               }
           }
@@ -1593,5 +1617,5 @@
             if (DEBUG)
               {
-                cout << "Doesn't satisfy requirements for circumscribing circle" << endl;
+                cout << Verbose(3) << *Candidate << " would have circumference of " << Umkreisradius << " bigger than ball's radius " << RADIUS << "." << endl;
               }
           }
@@ -1601,5 +1625,5 @@
         if (DEBUG)
           {
-            cout << "identisch mit Ursprungslinie" << endl;
+            cout << Verbose(3) << *Candidate << " is either " << *a << " or " << *b << "." << endl;
           }
       }
@@ -1625,4 +1649,5 @@
         }
     }
+  cout << Verbose(2) << "End of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n";
 }
 ;
@@ -1746,5 +1771,8 @@
           d1->ProjectOntoPlane(&AngleCheckReference);
           sign = AngleCheck.ScalarProduct(d1);
-          sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
+          if (fabs(sign) < MYEPSILON)
+            sign = 0;
+          else
+            sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
 
 
@@ -1904,5 +1932,5 @@
     const double& RADIUS, int N)
 {
-  cout << Verbose(1) << "Looking for next suitable triangle \n";
+  cout << Verbose(1) << "Begin of Find_next_suitable_triangle\n";
   Vector direction1;
   Vector helper;
@@ -1910,4 +1938,5 @@
   ofstream *tempstream = NULL;
   char filename[255];
+  double tmp;
   //atom* Walker;
 
@@ -1918,5 +1947,6 @@
   Vector Opt_Mittelpunkt;
 
-  cout << Verbose(1) << "Constructing helpful vectors ... " << endl;
+  cout << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl;
+
   helper.CopyVector(&(Line.endpoints[0]->node->x));
   for (int i = 0; i < 3; i++)
@@ -1938,27 +1968,43 @@
       direction1.Scale(-1);
     }
+  cout << Verbose(2) << "Looking in direction " << direction1 << " for candidates.\n";
 
   Chord.CopyVector(&(Line.endpoints[0]->node->x)); // bring into calling function
   Chord.SubtractVector(&(Line.endpoints[1]->node->x));
-
-
-    Vector Umkreismittelpunkt, a, b, c;
-    double alpha, beta, gamma;
-    a.CopyVector(&(T.endpoints[0]->node->x));
-    b.CopyVector(&(T.endpoints[1]->node->x));
-    c.CopyVector(&(T.endpoints[2]->node->x));
-    a.SubtractVector(&(T.endpoints[1]->node->x));
-    b.SubtractVector(&(T.endpoints[2]->node->x));
-    c.SubtractVector(&(T.endpoints[0]->node->x));
-
-    alpha = M_PI - a.Angle(&c);
-    beta = M_PI - b.Angle(&a);
-    gamma = M_PI - c.Angle(&b);
-
-    Umkreismittelpunkt = (T.endpoints[0]->node->x) * sin(2.*alpha) + T.endpoints[1]->node->x * sin(2.*beta) + (T.endpoints[2]->node->x) * sin(2.*gamma) ;
-    cout << "UmkreisMittelpunkt is " << Umkreismittelpunkt.x[0] << " "<< Umkreismittelpunkt.x[1] << " "<< Umkreismittelpunkt.x[2] << " "<< endl;
-    Umkreismittelpunkt.Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma)));
-    cout << "UmkreisMittelpunkt is " << Umkreismittelpunkt.x[0] << " "<< Umkreismittelpunkt.x[1] << " "<< Umkreismittelpunkt.x[2] << " "<< endl;
-
+  cout << Verbose(2) << "Baseline vector is " << Chord << ".\n";
+
+
+  Vector Umkreismittelpunkt, a, b, c;
+  double alpha, beta, gamma;
+  a.CopyVector(&(T.endpoints[0]->node->x));
+  b.CopyVector(&(T.endpoints[1]->node->x));
+  c.CopyVector(&(T.endpoints[2]->node->x));
+  a.SubtractVector(&(T.endpoints[1]->node->x));
+  b.SubtractVector(&(T.endpoints[2]->node->x));
+  c.SubtractVector(&(T.endpoints[0]->node->x));
+
+  alpha = a.Angle(&c) - M_PI/2.;
+  beta = b.Angle(&a);
+  gamma = c.Angle(&b) - M_PI/2.;
+  if (fabs(M_PI - alpha - beta - gamma) > MYEPSILON)
+    cerr << Verbose(0) << "WARNING: sum of angles for candidate triangle " << (alpha + beta + gamma)/M_PI*180. << " != 180.\n";
+
+  cout << Verbose(2) << "Base triangle has sides " << a << ", " << b << ", " << c << " with angles " << alpha/M_PI*180. << ", " << beta/M_PI*180. << ", " << gamma/M_PI*180. << "." << endl;
+  Umkreismittelpunkt = (T.endpoints[0]->node->x) * sin(2.*alpha) + T.endpoints[1]->node->x * sin(2.*beta) + (T.endpoints[2]->node->x) * sin(2.*gamma) ;
+  Umkreismittelpunkt.Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma)));
+  cout << Verbose(2) << "Center of circumference is " << Umkreismittelpunkt << "." << endl;
+  if (DEBUG)
+    cout << Verbose(3) << "Check of relative endpoints (same distance, equally spreaded): "<< endl;
+  tmp = 0;
+  for (int i=0;i<NDIM;i++) {
+    helper.CopyVector(&T.endpoints[i]->node->x);
+    helper.SubtractVector(&Umkreismittelpunkt);
+    if (DEBUG)
+      cout << Verbose(3) << "Endpoint[" << i << "]: " << helper << " with length " << helper.Norm() << "." << endl;
+    if (tmp == 0) // set on first time for comparison against next ones
+      tmp = helper.Norm();
+    if (fabs(helper.Norm() - tmp) > MYEPSILON)
+      cerr << Verbose(1) << "WARNING: center of circumference is wrong!" << endl;
+  }
 
   cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl;
@@ -1974,4 +2020,5 @@
   if ((TrianglesOnBoundaryCount % 10) == 0)
     {
+    cout << Verbose(1) << "Writing temporary non convex hull to file testEnvelope-" << TriangleFilesWritten << "d.dat.\n";
     sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten);
     tempstream = new ofstream(filename, ios::trunc);
@@ -1984,12 +2031,12 @@
   if (TrianglesOnBoundaryCount >1000 )
     {
-      cout << Verbose(1)
-          << "No new Atom found, triangle construction will crash" << endl;
+      cerr << Verbose(0)
+          << "WARNING: Already more than " << TrianglesOnBoundaryCount-1 << "triangles, construction probably has crashed." << endl;
       write_tecplot_file(out, tecplot, this, mol, TriangleFilesWritten);
-      cout << "This is currently added candidate" << Opt_Candidate << endl;
+      cout << Verbose(2) << "This is currently added candidate" << Opt_Candidate << endl;
     }
   // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
 
-  cout << " Optimal candidate is " << *Opt_Candidate << endl;
+  cout << Verbose(2) << " Optimal candidate is " << *Opt_Candidate << endl;
 
   AddTrianglePoint(Opt_Candidate, 0);
@@ -2003,16 +2050,15 @@
   BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
   AddTriangleToLines();
-  cout << "New triangle with " << *BTS << endl;
-  cout << "We have "<< TrianglesOnBoundaryCount << endl;
-  cout << Verbose(1) << "Constructing normal vector for this triangle ... " << endl;
-
-  BTS->GetNormalVector(BTS->NormalVector);
-
-  if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0)  ||
-      (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0))
-    {
-      BTS->NormalVector.Scale(-1);
-    };
-
+
+  BTS->GetNormalVector(T.NormalVector);
+
+//  if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0)  ||
+//      (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0))
+//    {
+//      BTS->NormalVector.Scale(-1);
+//    };
+  cout << Verbose(2) << "New triangle with " << *BTS << "and normal vector " << BTS->NormalVector << " for this triangle ... " << endl;
+  cout << Verbose(2) << "We have "<< TrianglesOnBoundaryCount << " for line " << Line << "." << endl;
+  cout << Verbose(1) << "End of Find_next_suitable_triangle\n";
 }
 ;
@@ -2022,15 +2068,16 @@
     molecule* mol, double RADIUS)
 {
-  cout << Verbose(1)
-      << "Looking for second point of starting triangle, recursive level "
-      << RecursionLevel << endl;;
+  cout << Verbose(2)
+      << "Begin of Find_second_point_for_Tesselation, recursive level "
+      << RecursionLevel << endl;
   int i;
   Vector AngleCheck;
   atom* Walker;
-  double norm = -1.;
+  double norm = -1., angle;
 
   // check if we only have one unique point yet ...
   if (a != Candidate)
     {
+    cout << Verbose(3) << "Current candidate is " << *Candidate << ": ";
       AngleCheck.CopyVector(&(Candidate->x));
       AngleCheck.SubtractVector(&(a->x));
@@ -2039,9 +2086,9 @@
       if (norm < RADIUS)
         {
-          if (AngleCheck.Angle(&Oben) < Storage[0])
+        angle = AngleCheck.Angle(&Oben);
+          if (angle < Storage[0])
             {
               //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
-              cout << "Next better candidate is " << *Candidate
-                  << " with distance " << norm << ".\n";
+              cout << "Is a better candidate with distance " << norm << " and " << angle << ".\n";
               Opt_Candidate = Candidate;
               Storage[0] = AngleCheck.Angle(&Oben);
@@ -2050,5 +2097,5 @@
           else
             {
-              cout << Verbose(1) << "Supposedly looses to a better candidate "
+              cout << "Looses with angle " << angle << " to a better candidate "
                   << *Opt_Candidate << endl;
             }
@@ -2056,5 +2103,5 @@
       else
         {
-          cout << Verbose(1) << *Candidate << " refused due to Radius " << norm
+          cout << "Refused due to Radius " << norm
               << endl;
         }
@@ -2075,4 +2122,6 @@
         };
     };
+  cout << Verbose(2) << "End of Find_second_point_for_Tesselation, recursive level "
+      << RecursionLevel << endl;
 }
 ;
@@ -2080,11 +2129,11 @@
 void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS)
 {
-  cout << Verbose(1) << "Looking for starting triangle \n";
+  cout << Verbose(1) << "Begin of Find_starting_triangle\n";
   int i = 0;
   atom* Walker;
   atom* FirstPoint;
   atom* SecondPoint;
-  atom* max_index[3];
-  double max_coordinate[3];
+  atom* max_index[NDIM];
+  double max_coordinate[NDIM];
   Vector Oben;
   Vector helper;
@@ -2099,5 +2148,5 @@
       max_coordinate[i] = -1;
     }
-  cout << Verbose(1) << "Molecule mol is there and has " << mol->AtomCount
+  cout << Verbose(2) << "Molecule mol is there and has " << mol->AtomCount
       << " Atoms \n";
 
@@ -2117,5 +2166,8 @@
     }
 
-  cout << Verbose(1) << "Found maximum coordinates. " << endl;
+  cout << Verbose(2) << "Found maximum coordinates: ";
+  for (int i=0;i<NDIM;i++)
+    cout << i << ": " << *max_index[i] << "\t";
+  cout << endl;
   //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0
   const int k = 1;
@@ -2123,17 +2175,14 @@
   FirstPoint = max_index[k];
 
-  cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << ": "
-      << FirstPoint->x.x[0] << endl;
+  cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << " with " << mol->NumberOfBondsPerAtom[FirstPoint->nr] << " bonds." << endl;
   double Storage[2];
   atom* Opt_Candidate = NULL;
   Storage[0] = 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.
   Storage[1] = 999999.; // This will be an angle looking for the third point.
-  cout << Verbose(1) << "Number of Bonds: "
-      << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl;
 
   Find_second_point_for_Tesselation(FirstPoint, FirstPoint, FirstPoint, 0,
       Oben, Opt_Candidate, Storage, mol, RADIUS); // we give same point as next candidate as its bonds are looked into in find_second_...
   SecondPoint = Opt_Candidate;
-  cout << Verbose(1) << "Found second point is " << *SecondPoint << ".\n";
+  cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n";
 
   helper.CopyVector(&(FirstPoint->x));
@@ -2150,5 +2199,5 @@
   // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized)
 
-  cout << Verbose(1) << "Looking for third point candidates \n";
+  cout << Verbose(2) << "Looking for third point candidates \n";
   // look in one direction of baseline for initial candidate
   Opt_Candidate = NULL;
@@ -2157,7 +2206,9 @@
   CenterOfFirstLine.AddVector(&(SecondPoint->x));
 
+  cout << Verbose(1) << "Looking for third point candidates from " << *FirstPoint << " onward ...\n";
   Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, 0,
       &Chord, &helper, &Oben, CenterOfFirstLine,  Opt_Candidate, Storage, RADIUS, mol);
   // look in other direction of baseline for possible better candidate
+  cout << Verbose(1) << "Looking for third point candidates from " << *SecondPoint << " onward ...\n";
   Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, FirstPoint, SecondPoint, 0,
       &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol);
@@ -2165,8 +2216,4 @@
 
   // FOUND Starting Triangle: FirstPoint, SecondPoint, Opt_Candidate
-
-  cout << Verbose(1) << "The found starting triangle consists of "
-      << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate
-      << "." << endl;
 
   // Finally, we only have to add the found points
@@ -2184,4 +2231,8 @@
   Oben.Scale(-1.);
   BTS->GetNormalVector(Oben);
+  cout << Verbose(0) << "==> The found starting triangle consists of "
+      << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate
+      << " with normal vector " << BTS->NormalVector << ".\n";
+  cout << Verbose(1) << "End of Find_starting_triangle\n";
 }
 ;
@@ -2195,20 +2246,22 @@
   const double RADIUS = 6.;
   LineMap::iterator baseline;
+  cout << Verbose(0) << "Begin of Find_non_convex_border\n";
+  bool flag = false;  // marks whether we went once through all baselines without finding any without two triangles
+
   Tess->Find_starting_triangle(mol, RADIUS);
 
   baseline = Tess->LinesOnBoundary.begin();
-  while (baseline != Tess->LinesOnBoundary.end())
+  while ((baseline != Tess->LinesOnBoundary.end()) || (!flag))
     {
       if (baseline->second->TrianglesCount == 1)
         {
-          cout << Verbose(1) << "Begin of Tesselation ... " << endl;
           Tess->Find_next_suitable_triangle(out, tecplot, mol,
               *(baseline->second),
               *(((baseline->second->triangles.begin()))->second), RADIUS, N); //the line is there, so there is a triangle, but only one.
-          cout << Verbose(1) << "End of Tesselation ... " << endl;
+          flag = true;
         }
       else
         {
-          cout << Verbose(1) << "There is a line with "
+          cout << Verbose(1) << "Line " << &baseline << " has "
               << baseline->second->TrianglesCount << " triangles adjacent"
               << endl;
@@ -2216,7 +2269,13 @@
       N++;
       baseline++;
-    }
+      if ((baseline == Tess->LinesOnBoundary.end()) && (flag)) {
+        baseline = Tess->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
+        flag = false;
+      }
+    }
+  cout << Verbose(1) << "Writing final tecplot file\n";
   write_tecplot_file(out, tecplot, Tess, mol, -1);
 
-}
-;
+  cout << Verbose(0) << "End of Find_non_convex_border\n";
+}
+;
Index: src/vector.cpp
===================================================================
--- src/vector.cpp	(revision 7c6712a25ea23cdfa7e88b8f2293af4c65278eec)
+++ src/vector.cpp	(revision 44fd957c290401f17701bb788d3d339733fe6b38)
@@ -219,5 +219,5 @@
  * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
  */
-double Vector::Angle(Vector *y) const
+double Vector::Angle(const Vector *y) const
 {
   return acos(this->ScalarProduct(y)/Norm()/y->Norm());
@@ -313,7 +313,18 @@
 };
 
-ofstream& operator<<(ofstream& ost,Vector& m)
-{
-	m.Output(&ost);
+/** Prints a 3dim vector to a stream.
+ * \param ost output stream
+ * \param v Vector to be printed
+ * \return output stream
+ */
+ostream& operator<<(ostream& ost,Vector& m)
+{
+  ost << "(";
+  for (int i=0;i<NDIM;i++) {
+    ost << m.x[i];
+    if (i != 2)
+      ost << ",";
+  }
+  ost << ")";
 	return ost;
 };
Index: src/vector.hpp
===================================================================
--- src/vector.hpp	(revision 7c6712a25ea23cdfa7e88b8f2293af4c65278eec)
+++ src/vector.hpp	(revision 44fd957c290401f17701bb788d3d339733fe6b38)
@@ -21,5 +21,5 @@
   double Projection(const Vector *y) const;
   double Norm() const ;
-  double Angle(Vector *y) const;
+  double Angle(const Vector *y) const;
 
   void AddVector(const Vector *y);
@@ -55,5 +55,5 @@
 };
 
-ofstream& operator<<(ofstream& ost, Vector& m);
+ostream & operator << (ostream& ost, Vector &m);
 Vector& operator+=(Vector& a, const Vector& b);
 Vector& operator*=(Vector& a, const double m);
