Index: /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 5606)
+++ /issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 5607)
@@ -90,7 +90,7 @@
 			if (tb.det>0){ 
 				//Area coordinate
-				areacoord[0]= (double) dete[0]/ tb.det;
-				areacoord[1]= (double) dete[1] / tb.det;
-				areacoord[2]= (double) dete[2] / tb.det;
+				areacoord[0]= (double) dete[0]/tb.det;
+				areacoord[1]= (double) dete[1]/tb.det;
+				areacoord[2]= (double) dete[2]/tb.det;
 				//3 vertices of the triangle
 				i0=Th.GetId(tb[0]);
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	(revision 5606)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	(revision 5607)
@@ -14,8 +14,8 @@
 
 	/*DataSets*/
-	Loads*    loads    = NULL;
-	Icefront*   icefront = NULL;
-	Riftfront*  riftfront= NULL;
-	Pengrid*    pengrid  = NULL;
+	Loads     *loads     = NULL;
+	Icefront  *icefront  = NULL;
+	Riftfront *riftfront = NULL;
+	Pengrid   *pengrid   = NULL;
 
 	/*Intermediary*/
@@ -150,6 +150,5 @@
 	for(i=0;i<iomodel->numrifts;i++){
 
-		if(iomodel->my_elements[(int)*(iomodel->riftinfo+RIFTINFOSIZE*i+2)]){
-
+		if(iomodel->my_elements[(int)*(iomodel->riftinfo+RIFTINFOSIZE*i+2)-1]){
 			loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,DiagnosticHorizAnalysisEnum));
 			count++;
Index: /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 5606)
+++ /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 5607)
@@ -87,5 +87,5 @@
 		if(my_rank==epart[i]){ 
 
-			my_elements[i]=1;
+			my_elements[i]=true;
 			
 			/*Now that we are here, we can also start building the list of vertices belonging to this cpu partition: we use 
@@ -93,12 +93,12 @@
 			 into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices 
 			 will hold which vertices belong to this partition*/
-			my_vertices[(int)*(iomodel->elements+elements_width*i+0)-1]=1;
-			my_vertices[(int)*(iomodel->elements+elements_width*i+1)-1]=1;
-			my_vertices[(int)*(iomodel->elements+elements_width*i+2)-1]=1;
+			my_vertices[(int)*(iomodel->elements+elements_width*i+0)-1]=true;
+			my_vertices[(int)*(iomodel->elements+elements_width*i+1)-1]=true;
+			my_vertices[(int)*(iomodel->elements+elements_width*i+2)-1]=true;
 			
 			if(elements_width==6){
-				my_vertices[(int)*(iomodel->elements+elements_width*i+3)-1]=1;
-				my_vertices[(int)*(iomodel->elements+elements_width*i+4)-1]=1;
-				my_vertices[(int)*(iomodel->elements+elements_width*i+5)-1]=1;
+				my_vertices[(int)*(iomodel->elements+elements_width*i+3)-1]=true;
+				my_vertices[(int)*(iomodel->elements+elements_width*i+4)-1]=true;
+				my_vertices[(int)*(iomodel->elements+elements_width*i+5)-1]=true;
 			}
 		}
Index: /issm/trunk/src/c/objects/Hook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Hook.cpp	(revision 5606)
+++ /issm/trunk/src/c/objects/Hook.cpp	(revision 5607)
@@ -185,4 +185,5 @@
 
 		/*demarshall allocated ids and offsets: */
+		ISSMASSERT(num<1000);
 		for (i=0;i<num;i++){
 			memcpy(&this->ids[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
Index: /issm/trunk/src/c/objects/Loads/Riftfront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 5606)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 5607)
@@ -215,5 +215,4 @@
 	return sizeof(id)
 		+sizeof(analysis_type)
-
 		+sizeof(active)
 		+sizeof(normal)
Index: /issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp
===================================================================
--- /issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp	(revision 5606)
+++ /issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp	(revision 5607)
@@ -22,8 +22,7 @@
 	double fx1,fx2,fxbest;
 	double x1,x2,xmin,xbest;
-	double distance;
 
 	/*tolerances: */
-	double tol1,tol2,seps,tolerance;
+	double seps,tolerance;
 	int    maxiter;
 
@@ -47,6 +46,4 @@
 	//update tolerances
 	seps=sqrt(DBL_EPSILON);
-	tol1=seps*sqrt(pow(x1,2))+tolerance/3.0;
-	tol2=2.0*tol1;
 
 	loop=true;
@@ -57,11 +54,9 @@
 		fx2 = (*f)(x2,optargs);
 		if isnan(fx2) ISSMERROR("Function evaluation returned NaN");
-		_printf_("         %5i    %12.6g  %12.6g  %12.6g\n",iter,x2,fx2,pow(pow(x2-x1,2),0.5));
+		_printf_("         %5i    %12.6g  %12.6g  %12.6g\n",iter,x2,fx2,fabs(x2-x1)>fabs(fx2-fx1)?fabs(fx2-fx1):fabs(x2-x1));
 
 		//Stop the optimization?
-		tol1=seps*pow(pow(x2,2),0.5)+tolerance/3.0;
-		tol2=2.0*tol1;
-		if (sqrt(pow(x2-x1,2)) < (tol2-0.5*(distance))){
-			_printf_("      %s%g\n","optimization terminated: the current x satisfies the termination criteria using 'tolx' of" ,tolerance);
+		if ((fabs(x2-x1)+seps)<tolerance || (fabs(fx2-fx1)+seps)<tolerance){
+			_printf_("      %s%g\n","optimization terminated: the current x satisfies the termination criteria using 'tolx' of " ,tolerance);
 			loop=false;
 		}
