Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15282)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 15283)
@@ -6050,5 +6050,9 @@
 
 	/*Check that all nodes are active, else return empty matrix*/
-	if(!this->AllActive()) return NULL;
+	if(!this->AllActive()){
+		delete gauss;
+		return NULL;
+	}
+
 	/*Initialize Element matrix*/
 	ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
@@ -6221,6 +6225,8 @@
 
 	/*Check that all nodes are active, else return empty matrix*/
-	if(!this->AllActive()) return NULL;
-
+	if(!this->AllActive()){
+		delete gauss;
+		return NULL;
+	}
 	/*Initialize Element vector*/
 	ElementVector* pe=new ElementVector(nodes,NUMVERTICES,this->parameters);
@@ -6260,7 +6266,7 @@
 		}
 	}
-
+	delete gauss;
+	
 	/*	Add residual if necessary*/
-	delete gauss;
 	gauss=new GaussTria();
 	for(int iv=0;iv<NUMVERTICES;iv++){
@@ -6490,5 +6496,4 @@
 		/*Assign output pointer*/
 		*ph_max=h_max;
-
 }
 /*}}}*/
@@ -6520,4 +6525,5 @@
 		case 0:
 			/*Just kipping the transfer to zero*/
+			wh_trans=0.0;
 			break;
 		case 1:
@@ -6533,5 +6539,8 @@
 			
 			for(int i=0;i<numdof;i++){
-				if(activeEpl[i]==0.0)continue;
+				if(activeEpl[i]==0.0){
+					wh_trans=0.0;
+					continue;
+				}
 				
 				eplstoring[i]=matpar->GetEplStoring();		
@@ -6556,4 +6565,6 @@
 		}
 	}
+	/*Free ressources:*/
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -6604,5 +6615,4 @@
 	
 	for(i=0;i<numdof;i++){
-
 		/*Activate EPL if residual is >0 */
 		if(residual[i]>0.){
@@ -6615,11 +6625,11 @@
 		}
 
-		/*Increase the size of the efficient system if needed*/
-		/*Increase is needed if the epl head reach the maximum value (sediment value for now)*/
+		/*Increase of the efficient system is needed if the epl head reach the maximum value (sediment max value for now)*/
 		this->GetHydrologyDCInefficientHmax(&h_max,nodes[i]);
-		if(eplhead[i]>=h_max){
-			vec_mask->SetValue(nodes[i]->Sid(),1.,INS_VAL);
+		if(eplhead[i]>=h_max && this->AnyActive()){			
 			for(j=0;j<numdof;j++){
-				
+				if(old_active[j]>0.){
+					vec_mask->SetValue(nodes[i]->Sid(),1.,INS_VAL);
+				}
 				/*Increase of the domain is on the downstream node in term of sediment head*/
 				if(sedhead[j] == sedheadmin){
Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 15282)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 15283)
@@ -1583,8 +1583,8 @@
 void FemModel::HydrologyEPLupdateDomainx(void){ /*{{{*/
 
-	Vector<IssmDouble> *mask          = NULL;
-	IssmDouble         *serial_mask   = NULL;
-	Vector<IssmDouble> *active        = NULL;
-	IssmDouble         *serial_active = NULL;
+	Vector<IssmDouble>* mask          = NULL;
+	IssmDouble*         serial_mask   = NULL;
+	Vector<IssmDouble>* active        = NULL;
+	IssmDouble*         serial_active = NULL;
 
 	/*Step 1: update maks, the mask might be extended by residual and/or using downstream sediment head*/
@@ -1661,4 +1661,5 @@
 	InputUpdateFromVectorx(elements,nodes,vertices,loads,materials,parameters,transferg,WaterTransferEnum,NodesEnum);
 
-}
-/*}}}*/
+	delete transferg;
+}
+/*}}}*/
