Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15285)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15286)
@@ -6051,5 +6051,4 @@
 	/*Check that all nodes are active, else return empty matrix*/
 	if(!this->AllActive()){
-		delete gauss;
 		return NULL;
 	}
@@ -6226,5 +6225,4 @@
 	/*Check that all nodes are active, else return empty matrix*/
 	if(!this->AllActive()){
-		delete gauss;
 		return NULL;
 	}
@@ -6524,6 +6522,5 @@
 		switch(transfermethod){
 		case 0:
-			/*Just kipping the transfer to zero*/
-			wh_trans=0.0;
+			/*Just keepping the transfer to zero, should be OK with the initial value of transfer*/
 			break;
 		case 1:
@@ -6539,20 +6536,23 @@
 			
 			for(int i=0;i<numdof;i++){
+				/*No transfer if the EPL is not active*/
 				if(activeEpl[i]==0.0){
 					wh_trans=0.0;
-					continue;
-				}
-				
-				eplstoring[i]=matpar->GetEplStoring();		
-				sedstoring[i]=matpar->GetSedimentStoring();
-				
-				if(sed_head[i]>epl_head[i]){
-					wh_trans=sed_trans*sedstoring[i]*(epl_head[i]-sed_head[i])/(leakage*sed_thick);				
 				}
 				else{
-					this->GetHydrologyDCInefficientHmax(&h_max,nodes[i]);
-					wh_trans=sed_trans*eplstoring[i]*(epl_head[i]-sed_head[i])/(leakage*sed_thick);
-					if(sed_head[i]>=h_max){
-						wh_trans=0.0;
+					eplstoring[i]=matpar->GetEplStoring();		
+					sedstoring[i]=matpar->GetSedimentStoring();
+					
+					/*EPL head higher than sediment head, transfer from the epl to the sediment*/
+					if(epl_head[i]>sed_head[i]){
+						wh_trans=eplstoring[i]*sed_trans*(epl_head[i]-sed_head[i])/(leakage*sed_thick);				
+						
+						/*No transfer if the sediment head is allready at the maximum*/
+						this->GetHydrologyDCInefficientHmax(&h_max,nodes[i]);
+						if(sed_head[i]>=h_max)wh_trans=0.0;
+					}
+					/*EPL head lower than sediment head, transfer from the sediment to the epl*/
+					else if(epl_head[i]<sed_head[i]){
+						wh_trans=sedstoring[i]*sed_trans*(epl_head[i]-sed_head[i])/(leakage*sed_thick);				
 					}
 				}
@@ -6635,5 +6635,5 @@
 				if(sedhead[j] == sedheadmin){
 					vec_mask->SetValue(nodes[j]->Sid(),1.,INS_VAL);
-					break;
+					//	break;
 				}
 			}
