Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp	(revision 10531)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp	(revision 10532)
@@ -297,9 +297,4 @@
 					}
 
-					/*Constraint at the bedrock interface (v.n = vz = 0) (Coordinates will be updated according to the bed slope)*/
-					if(nodeonbed[i] && nodeonicesheet[i] && nodeonstokes[i]){
-						constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0.,DiagnosticHorizAnalysisEnum));
-						count++;
-					}
 				}
 				if ((int)vertices_type[i]==NoneApproximationEnum){
@@ -308,4 +303,10 @@
 				}
 
+			}
+
+			/*Constraint at the bedrock interface (v.n = vz = 0) (Coordinates will be updated according to the bed slope)*/
+			if(nodeonbed[i] && nodeonicesheet[i] && nodeonstokes[i]){
+				constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,0.,DiagnosticHorizAnalysisEnum));
+				count++;
 			}
 		}
Index: /issm/trunk/src/c/shared/Elements/CoordinateSystemTransform.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/CoordinateSystemTransform.cpp	(revision 10531)
+++ /issm/trunk/src/c/shared/Elements/CoordinateSystemTransform.cpp	(revision 10532)
@@ -9,5 +9,5 @@
 	int     i,counter;
 	int     numdofs           = 0;
-	double  x_norm,y_norm;
+	double  norm;
 	double *transform         = NULL;
 	double *values            = NULL;
@@ -44,11 +44,10 @@
 		switch(cs_array[i]){
 			case XYEnum:
-				/*We remove the z component, we need to renormalize x and y*/
-				x_norm = sqrt( coord_system[0][0]*coord_system[0][0] + coord_system[1][0]*coord_system[1][0]); _assert_(x_norm>1.e-5);
-				y_norm = sqrt( coord_system[0][1]*coord_system[0][1] + coord_system[1][1]*coord_system[1][1]); _assert_(y_norm>1.e-5);
-				transform[(numdofs)*(counter+0) + counter+0] = coord_system[0][0]/x_norm;
-				transform[(numdofs)*(counter+0) + counter+1] = coord_system[0][1]/y_norm;
-				transform[(numdofs)*(counter+1) + counter+0] = coord_system[1][0]/x_norm;
-				transform[(numdofs)*(counter+1) + counter+1] = coord_system[1][1]/y_norm;
+				/*We remove the z component, we need to renormalize x and y: x=[x1 x2 0] y=[-x2 x1 0]*/
+				norm = sqrt( coord_system[0][0]*coord_system[0][0] + coord_system[1][0]*coord_system[1][0]); _assert_(norm>1.e-4);
+				transform[(numdofs)*(counter+0) + counter+0] =   coord_system[0][0]/norm;
+				transform[(numdofs)*(counter+0) + counter+1] = - coord_system[1][0]/norm;
+				transform[(numdofs)*(counter+1) + counter+0] =   coord_system[1][0]/norm;
+				transform[(numdofs)*(counter+1) + counter+1] =   coord_system[0][0]/norm;
 				counter+=2;
 				break;
