Index: /issm/trunk/src/c/objects/Bamg/Mesh.cpp
===================================================================
--- /issm/trunk/src/c/objects/Bamg/Mesh.cpp	(revision 5580)
+++ /issm/trunk/src/c/objects/Bamg/Mesh.cpp	(revision 5581)
@@ -2735,5 +2735,5 @@
 		if (verbose>2) printf("   Insert initial %i vertices\n",nbv);
 
-		//Compute integer coordinates and determinants for the existing vertices (from Geometry)
+		//Compute integer coordinates for the existing vertices
 		SetIntCoor();
 
@@ -2765,9 +2765,12 @@
 		 *  We hence have built a random list of nbv elements of
 		 *  [0 nbv[ all distincts*/
-		for (i=0;i<nbv;i++) ordre[i]= &vertices[i] ;
-		const long PrimeNumber= BigPrimeNumber(nbv) ;
+
+		//Get Prime number
+		const long PrimeNumber= BigPrimeNumber(nbv);
 		int   k0=rand()%nbv; 
-		for (int is3=0; is3<nbv; is3++){
-			ordre[is3]= &vertices[k0=(k0+PrimeNumber)%nbv];
+
+		//Build ordre
+		for (i=0; i<nbv; i++){
+			ordre[i]=&vertices[k0=(k0+PrimeNumber)%nbv];
 		}
 
@@ -2775,10 +2778,8 @@
 
 		//get first vertex i such that [0,1,i] are not aligned
-		for (i=2 ; det( ordre[0]->i, ordre[1]->i, ordre[i]->i ) == 0;){
+		for (i=2; det(ordre[0]->i,ordre[1]->i,ordre[i]->i)==0){
 			//if i is higher than nbv, it means that all the determinants are 0,
 			//all vertices are aligned!
-			if  ( ++i >= nbv) {
-				ISSMERROR("all the vertices are aligned");
-			}
+			if  (++i>=nbv) ISSMERROR("all the vertices are aligned");
 		}
 		// exchange i et 2 in "ordre" so that
@@ -5057,4 +5058,13 @@
 									while(s>=lcurve && s<=lcurveb && nbv<nbvend){
 
+										/*Schematic of current curve
+										 *
+										 *  a                   vb                  b          // vertex
+										 *  0              ll0     ll1              ledge      // length from a
+										 *  + --- + - ... - + --S-- + --- + - ... - +          // where is S
+										 *  0              kk0     kk1              NbSubEdge  // Sub edge index
+										 *
+										 */
+
 										double ss = s-lcurve;
 
@@ -5070,6 +5080,13 @@
 										ISSMASSERT(kk1!=kk0);
 
-										double sbb = (ss-ll0  )/(ll1-ll0);
-										double bb = (kk1+sbb)/NbSubEdge, aa=1-bb;
+										/*Curvilinear coordinate in [0 1] of ss in current edge*/
+										// WARNING: This is what we would do
+										// ssa = (ss-ll0)/(ll1-ll0);
+										// aa = (kk0+ssa)/NbSubEdge
+										// This is what Bamg does:
+										double sbb = (ss-ll0)/(ll1-ll0);
+										/*Curvilinear coordinate in [0 1] of ss in current curve*/
+										double bb = (kk1+sbb)/NbSubEdge;
+										double aa = 1-bb;
 
 										// new vertex on edge
@@ -5079,5 +5096,5 @@
 										vb->DirOfSearch =NoDirOfSearch;
 										double abcisse = k ? bb : aa;
-										vb->r =  e->F( abcisse );
+										vb->r =  e->F(abcisse);
 										VerticesOnGeomEdge[NbVerticesOnGeomEdge++]= VertexOnGeom(*vb,*e,abcisse);        
 
Index: /issm/trunk/src/c/shared/Bamg/det.h
===================================================================
--- /issm/trunk/src/c/shared/Bamg/det.h	(revision 5580)
+++ /issm/trunk/src/c/shared/Bamg/det.h	(revision 5581)
@@ -7,6 +7,6 @@
 
 	Icoor2 inline det(const I2 &a,const I2 & b,const I2 &c){
-		register  Icoor2 bax = b.x - a.x ,bay = b.y - a.y; 
-		register  Icoor2 cax = c.x - a.x ,cay = c.y - a.y; 
+		Icoor2 bax = b.x - a.x ,bay = b.y - a.y; 
+		Icoor2 cax = c.x - a.x ,cay = c.y - a.y; 
 		return  bax*cay - bay*cax;
 	}
