Index: /issm/trunk/src/c/DataSet/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 3964)
+++ /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 3965)
@@ -651,27 +651,4 @@
 }
 /*}}}*/
-/*FUNCTION DataSet::CreateKMatrix{{{1*/
-void  DataSet::CreateKMatrix(Mat Kgg,int analysis_type,int sub_analysis_type){
-
-	vector<Object*>::iterator object;
-	Element* element=NULL;
-	Load* load=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		
-		if(EnumIsElement((*object)->Enum())){
-
-			element=(Element*)(*object);
-			element->CreateKMatrix(Kgg,analysis_type,sub_analysis_type);
-		}
-		if(EnumIsLoad((*object)->Enum())){
-
-			load=(Load*)(*object);
-			load->CreateKMatrix(Kgg,analysis_type,sub_analysis_type);
-		}
-	}
-
-}
-/*}}}*/
 /*FUNCTION DataSet::CreatePartitioningVector{{{1*/
 void  DataSet::CreatePartitioningVector(Vec* ppartition,int numberofobjects){
@@ -700,27 +677,4 @@
 	/*Assign output pointers: */
 	*ppartition=partition;
-}
-/*}}}*/
-/*FUNCTION DataSet::CreatePVector{{{1*/
-void  DataSet::CreatePVector(Vec pg,int analysis_type,int sub_analysis_type){
-
-	vector<Object*>::iterator object;
-	Element* element=NULL;
-	Load* load=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		if(EnumIsElement((*object)->Enum())){
-
-			element=(Element*)(*object);
-			element->CreatePVector(pg,analysis_type,sub_analysis_type);
-		}
-		if(EnumIsLoad((*object)->Enum())){
-
-			load=(Load*)(*object);
-			load->CreatePVector(pg,analysis_type,sub_analysis_type);
-		}		
-	}
-
 }
 /*}}}*/
@@ -1240,38 +1194,4 @@
 
 
-
-}
-/*}}}*/
-/*FUNCTION DataSet::PenaltyCreateKMatrix{{{1*/
-void  DataSet::PenaltyCreateKMatrix(Mat Kgg,double kmax,int analysis_type,int sub_analysis_type){
-
-	vector<Object*>::iterator object;
-	Load* load=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		
-		if(EnumIsLoad((*object)->Enum())){
-
-			load=(Load*)(*object);
-			load->PenaltyCreateKMatrix(Kgg,kmax,analysis_type,sub_analysis_type);
-		}
-	}
-
-}
-/*}}}*/
-/*FUNCTION DataSet::PenaltyCreatePVector{{{1*/
-void  DataSet::PenaltyCreatePVector(Vec pg,double kmax,int analysis_type,int sub_analysis_type){
-
-	vector<Object*>::iterator object;
-	Load* load=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		if(EnumIsLoad((*object)->Enum())){
-
-			load=(Load*)(*object);
-			load->PenaltyCreatePVector(pg,kmax,analysis_type,sub_analysis_type);
-		}		
-	}
 
 }
Index: /issm/trunk/src/c/DataSet/DataSet.h
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.h	(revision 3964)
+++ /issm/trunk/src/c/DataSet/DataSet.h	(revision 3965)
@@ -69,6 +69,4 @@
 		void  SetSorting(int* in_sorted_ids,int* in_id_offsets);
 		void  Sort();
-		void  CreateKMatrix(Mat Kgg, int analysis_type,int sub_analysis_type);
-		void  CreatePVector(Vec pg, int analysis_type,int sub_analysis_type);
 		void  UpdateInputsFromConstant(double constant, int name);
 		void  UpdateInputsFromConstant(int constant, int name);
@@ -79,6 +77,4 @@
 		void  UpdateInputsFromSolution(double* solution,int analysis_type,int sub_analysis_type);
 		void  GetSolutionFromInputs(Vec solution, int analysis_type, int sub_analysis_type);
-		void  PenaltyCreateKMatrix(Mat Kgg,double kmax,int analysis_type,int sub_analysis_type);
-		void  PenaltyCreatePVector(Vec pg,double kmax,int analysis_type,int sub_analysis_type);
 		int   RiftIsPresent();
 		int   MeltingIsPresent();
Index: /issm/trunk/src/c/modules/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp	(revision 3964)
+++ /issm/trunk/src/c/modules/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp	(revision 3965)
@@ -14,13 +14,11 @@
 	
 	int i;
-
-	extern int num_procs;
-	extern int my_rank;
 	double kmax;
+	Load* load=NULL;
 	
 	/*First, get elements and loads configured: */
-	elements->Configure(elements,loads, nodes,vertices, materials,parameters);
-	nodes->Configure(elements,loads, nodes,vertices, materials,parameters);
-	loads->Configure(elements, loads, nodes,vertices, materials,parameters);
+	elements->  Configure(elements,loads, nodes,vertices, materials,parameters);
+	nodes->     Configure(elements,loads, nodes,vertices, materials,parameters);
+	loads->     Configure(elements, loads, nodes,vertices, materials,parameters);
 	parameters->Configure(elements,loads, nodes,vertices, materials,parameters);
 
@@ -29,20 +27,34 @@
 
 	/*Add penalties to stiffnesses, from loads: */
-	if(kflag)loads->PenaltyCreateKMatrix(Kgg,kmax,analysis_type,sub_analysis_type);
-	if(pflag)loads->PenaltyCreatePVector(pg,kmax,analysis_type,sub_analysis_type);
-	
-	/*Assemble matrices: */
 	if(kflag){
+
+		/*Fill stiffness matrix from loads: */
+		for (i=0;i<loads->Size();i++){
+			load=(Load*)loads->GetObjectByOffset(i);
+			load->PenaltyCreateKMatrix(Kgg,kmax,analysis_type,sub_analysis_type);
+		}
+
+		/*Assemble matrix and compress matrix to save memory: */
 		MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY);
 		MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY);
 		MatCompress(Kgg);
 	}
+
+	/*Add penalties to right hand side, from loads: */
 	if(pflag){
+
+		/*Fill right hand side vector, from loads: */
+		for (i=0;i<loads->Size();i++){
+			load=(Load*)loads->GetObjectByOffset(i);
+			load->PenaltyCreatePVector(pg,kmax,analysis_type,sub_analysis_type);
+		}
+
+		/*Assemble right hand side: */
 		VecAssemblyBegin(pg);
 		VecAssemblyEnd(pg);
 	}
-
-	/*Assign output pointers:*/
-	if(pkmax)*pkmax=kmax;
+	
+	/*Assign output pointer:*/
+	if(pkmax) *pkmax=kmax;
 
 }
Index: /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 3964)
+++ /issm/trunk/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 3965)
@@ -13,11 +13,11 @@
 		int kflag,int pflag,int analysis_type,int sub_analysis_type){
 	
-	extern int num_procs;
-	extern int my_rank;
-	
 	/*intermediary: */
 	int gsize;
+	int i,j;
 	int connectivity;
 	int numberofdofspernode;
+	Element* element=NULL;
+	Load*    load=NULL;
 	
 	/*output: */
@@ -26,7 +26,7 @@
 
 	/*First, get elements and loads configured: */
-	elements->Configure(elements,loads, nodes,vertices, materials,parameters);
-	nodes->Configure(elements,loads, nodes,vertices, materials,parameters);
-	loads->Configure(elements, loads, nodes,vertices, materials,parameters);
+	elements->  Configure(elements,loads, nodes,vertices, materials,parameters);
+	nodes->     Configure(elements,loads, nodes,vertices, materials,parameters);
+	loads->     Configure(elements, loads, nodes,vertices, materials,parameters);
 	parameters->Configure(elements,loads, nodes,vertices, materials,parameters);
 
@@ -38,23 +38,47 @@
 	gsize=nodes->NumberOfDofs();
 
-	/*Allocate Kgg and pg: */
-	if(kflag)Kgg=NewMat(gsize,gsize,NULL,&connectivity,&numberofdofspernode);
-	if(pflag)pg=NewVec(gsize);
+	/*Compute stiffness matrix*/
+	if(kflag){
 
-	/*Fill stiffness matrix and right hand side vector, from elements: */
-	if(kflag)elements->CreateKMatrix(Kgg,analysis_type,sub_analysis_type);
-	if(pflag)elements->CreatePVector(pg,analysis_type,sub_analysis_type);
-	
-	/*Fill stiffness matrix and right hand side vector, from loads: */
-	if(kflag)loads->CreateKMatrix(Kgg,analysis_type,sub_analysis_type);
-	if(pflag)loads->CreatePVector(pg,analysis_type,sub_analysis_type);
+		/*Allocate Kgg*/
+		Kgg=NewMat(gsize,gsize,NULL,&connectivity,&numberofdofspernode);
 
-	/*Assemble matrices: */
-	if(kflag){
+		/*Fill stiffness matrix from elements: */
+		for (i=0;i<elements->Size();i++){
+			element=(Element*)elements->GetObjectByOffset(i);
+			element->CreateKMatrix(Kgg,analysis_type,sub_analysis_type);
+		}
+
+		/*Fill stiffness matrix from loads: */
+		for (i=0;i<loads->Size();i++){
+			load=(Load*)loads->GetObjectByOffset(i);
+			load->CreateKMatrix(Kgg,analysis_type,sub_analysis_type);
+		}
+
+		/*Assemble matrix and compress matrix to save memory: */
 		MatAssemblyBegin(Kgg,MAT_FINAL_ASSEMBLY);
 		MatAssemblyEnd(Kgg,MAT_FINAL_ASSEMBLY);
 		MatCompress(Kgg);
 	}
+
+	/*Compute Load vector*/
 	if(pflag){
+
+		/*Allocate pg*/
+		pg=NewVec(gsize);
+
+		/*Fill right hand side vector, from elements: */
+		for (i=0;i<elements->Size();i++){
+			element=(Element*)elements->GetObjectByOffset(i);
+			element->CreatePVector(pg,analysis_type,sub_analysis_type);
+		}
+
+		/*Fill right hand side vector, from loads: */
+		for (i=0;i<loads->Size();i++){
+			load=(Load*)loads->GetObjectByOffset(i);
+			load->CreatePVector(pg,analysis_type,sub_analysis_type);
+		}
+
+		/*Assemble right hand side: */
 		VecAssemblyBegin(pg);
 		VecAssemblyEnd(pg);
@@ -64,3 +88,4 @@
 	*pKgg=Kgg;
 	*ppg=pg;
+
 }
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 3964)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 3965)
@@ -4844,4 +4844,14 @@
 }
 /*}}}*/
+/*FUNCTION Tria::UpdateInputsFromConstant(double value, int name);{{{1*/
+void  Tria::UpdateInputsFromConstant(double constant, int name){
+	/*Nothing updated for now*/
+}
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsFromConstant(bool value, int name);{{{1*/
+void  Tria::UpdateInputsFromConstant(bool constant, int name){
+	/*Nothing updated for now*/
+}
+/*}}}*/
 /*FUNCTION Tria::DepthAverageInputAtBase {{{1*/
 void  Tria::DepthAverageInputAtBase(int enum_type){
Index: /issm/trunk/src/c/objects/Elements/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.h	(revision 3964)
+++ /issm/trunk/src/c/objects/Elements/Tria.h	(revision 3965)
@@ -139,7 +139,7 @@
 		void  UpdateInputsFromVector(int* vector, int name, int type);
 		void  UpdateInputsFromVector(bool* vector, int name, int type);
-		void  UpdateInputsFromConstant(double constant, int name){ISSMERROR("Not implemented yet!");};
+		void  UpdateInputsFromConstant(double constant, int name);
 		void  UpdateInputsFromConstant(int constant, int name);
-		void  UpdateInputsFromConstant(bool constant, int name){ISSMERROR("Not implemented yet!");};
+		void  UpdateInputsFromConstant(bool constant, int name);
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Model.cpp
===================================================================
--- /issm/trunk/src/c/objects/Model.cpp	(revision 3964)
+++ /issm/trunk/src/c/objects/Model.cpp	(revision 3965)
@@ -88,5 +88,5 @@
 
 	_printf_("   reducing single point constraints vector:\n");
-	Reducevectorgtosx(&ys,&ys0, yg->vector,nodesets);
+	Reducevectorgtosx(&ys,yg->vector,nodesets);
 	
 	_printf_("   normalizing rigid body constraints matrix:\n");
@@ -166,5 +166,5 @@
 
 	_printf_("   reducing single point constraints vector:\n");
-	Reducevectorgtosx(&ys,&ys0, yg->vector,nodesets);
+	Reducevectorgtosx(&ys,yg->vector,nodesets);
 	
 	_printf_("   normalizing rigid body constraints matrix:\n");
