Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4396)
@@ -41,9 +41,10 @@
 /*}}}*/
 /*FUNCTION Penta::Penta(int id, int index, IoModel* iomodel,int nummodels) {{{1*/
-Penta::Penta(int penta_id, int index, IoModel* iomodel,int nummodels){ //i is the element index
-
-	IssmInt i;
-	int penta_matice_id;
-	int penta_matpar_id;
+Penta::Penta(int penta_id, int index, IoModel* iomodel,int nummodels):
+
+	PentaHook(nummodels,index+1,iomodel->numberofelements+1) //index+1: matice id, iomodel->numberofelements+1: matpar id
+                                                                      { //i is the element index
+
+	int i;
 	int penta_elements_ids[2];
 
@@ -51,8 +52,5 @@
 	this->id=penta_id;
 
-	/*hooks: */
-	penta_matice_id=index+1; //refers to the corresponding ice material object
-	penta_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
-
+	/*penta_elements_ids: */
 	if isnan(iomodel->upperelements[index]){
 		penta_elements_ids[1]=this->id; //upper penta is the same penta
@@ -68,8 +66,5 @@
 		penta_elements_ids[0]=(int)(iomodel->lowerelements[index]);
 	}
-	this->InitHookNodes(nummodels);this->nodes=NULL;
-	this->InitHookMatice(penta_matice_id);this->matice=NULL;
-	this->InitHookMatpar(penta_matpar_id);this->matpar=NULL;
-	this->InitHookNeighbors(penta_elements_ids);this->neighbors=NULL;
+	this->InitHookNeighbors(penta_elements_ids);
 
 	//this->parameters: we still can't point to it, it may not even exist. Configure will handle this.
@@ -79,4 +74,10 @@
 	this->inputs=new Inputs();
 	this->results=new Results();
+	
+	/*initialize pointers:*/
+	this->nodes=NULL;
+	this->matice=NULL;
+	this->matpar=NULL;
+	this->neighbors=NULL;
 }
 /*}}}*/
@@ -92,5 +93,13 @@
 	penta=new Penta();
 
-	/*copy fields: */
+	//deal with PentaHook mother class
+	penta->numanalyses=this->numanalyses;
+	penta->hnodes=new Hook*[penta->numanalyses];
+	for(i=0;i<penta->numanalyses;i++)penta->hnodes[i]=(Hook*)this->hnodes[i]->copy();
+	penta->hmatice=(Hook*)this->hmatice->copy();
+	penta->hmatpar=(Hook*)this->hmatpar->copy();
+	penta->hneighbors=(Hook*)this->hneighbors->copy();
+
+	/*deal with Penta  copy fields: */
 	penta->id=this->id;
 	if(this->inputs){
@@ -109,17 +118,10 @@
 	penta->parameters=this->parameters;
 
-	/*now deal with hooks and objects: */
-	penta->InitHookNodes(this->numanalyses);
-	for(i=0;i<this->numanalyses;i++)penta->hnodes[i].copy(&this->hnodes[i]);
-	penta->hmatice.copy(&this->hmatice);
-	penta->hmatpar.copy(&this->hmatpar);
-	penta->hneighbors.copy(&this->hneighbors);
-
 	/*recover objects: */
 	penta->nodes=(Node**)xmalloc(6*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
 	for(i=0;i<6;i++)penta->nodes[i]=this->nodes[i];
-	penta->matice=(Matice*)penta->hmatice.delivers();
-	penta->matpar=(Matpar*)penta->hmatpar.delivers();
-	penta->neighbors=(Penta**)penta->hneighbors.deliverp();
+	penta->matice=(Matice*)penta->hmatice->delivers();
+	penta->matpar=(Matpar*)penta->hmatpar->delivers();
+	penta->neighbors=(Penta**)penta->hneighbors->deliverp();
 
 	return penta;
@@ -167,11 +169,13 @@
 
 	/*allocate dynamic memory: */
-	InitHookNodes(numanalyses);
-
+	this->hnodes=new Hook*[this->numanalyses];
 	/*demarshall hooks: */
-	for(i=0;i<numanalyses;i++)hnodes[i].Demarshall(&marshalled_dataset);
-	hmatice.Demarshall(&marshalled_dataset);
-	hmatpar.Demarshall(&marshalled_dataset);
-	hneighbors.Demarshall(&marshalled_dataset);
+	for(i=0;i<numanalyses;i++){
+		hnodes[i]=new Hook();
+		hnodes[i]->Demarshall(&marshalled_dataset);
+	}
+	hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);
+	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
+	hneighbors=new Hook(); hneighbors->Demarshall(&marshalled_dataset);
 
 	/*pointers are garbage, until configuration is carried out: */
@@ -236,8 +240,8 @@
 
 	/*Marshall hooks: */
-	for(i=0;i<numanalyses;i++)hnodes[i].Marshall(&marshalled_dataset);
-	hmatice.Marshall(&marshalled_dataset);
-	hmatpar.Marshall(&marshalled_dataset);
-	hneighbors.Marshall(&marshalled_dataset);
+	for(i=0;i<numanalyses;i++)hnodes[i]->Marshall(&marshalled_dataset);
+	hmatice->Marshall(&marshalled_dataset);
+	hmatpar->Marshall(&marshalled_dataset);
+	hneighbors->Marshall(&marshalled_dataset);
 
 	/*Marshall inputs and results: */
@@ -267,12 +271,12 @@
 	int hnodes_size=0;;
 
-	for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i].MarshallSize();
+	for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i]->MarshallSize();
 
 	return sizeof(id)
 		+hnodes_size
 		+sizeof(numanalyses)
-		+hmatice.MarshallSize()
-		+hmatpar.MarshallSize()
-		+hneighbors.MarshallSize()
+		+hmatice->MarshallSize()
+		+hmatpar->MarshallSize()
+		+hneighbors->MarshallSize()
 		+inputs->MarshallSize()
 		+results->MarshallSize()
@@ -599,14 +603,14 @@
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	this->hnodes[analysis_counter].configure(nodesin);
-	this->hmatice.configure(materialsin);
-	this->hmatpar.configure(materialsin);
-	this->hneighbors.configure(elementsin);
+	this->hnodes[analysis_counter]->configure(nodesin);
+	this->hmatice->configure(materialsin);
+	this->hmatpar->configure(materialsin);
+	this->hneighbors->configure(elementsin);
 
 	/*Now, go pick up the objects inside the hooks: */
-	this->nodes=(Node**)this->hnodes[analysis_counter].deliverp();
-	this->matice=(Matice*)this->hmatice.delivers();
-	this->matpar=(Matpar*)this->hmatpar.delivers();
-	this->neighbors=(Penta**)this->hneighbors.deliverp();
+	this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
+	this->matice=(Matice*)this->hmatice->delivers();
+	this->matpar=(Matpar*)this->hmatpar->delivers();
+	this->neighbors=(Penta**)this->hneighbors->deliverp();
 
 	/*point parameters to real dataset: */
@@ -1779,5 +1783,5 @@
 /*Penta specific routines: */
 /*FUNCTION Penta::SpawnTria {{{1*/
-void*  Penta::SpawnTria(int g0, int g1, int g2){
+Tria*  Penta::SpawnTria(int g0, int g1, int g2){
 
 	int i;
@@ -1811,7 +1815,7 @@
 
 	/*recover nodes, matice and matpar: */
-	tria->nodes=(Node**)tria->hnodes[analysis_counter].deliverp();
-	tria->matice=(Matice*)tria->hmatice.delivers();
-	tria->matpar=(Matpar*)tria->hmatpar.delivers();
+	tria->nodes=(Node**)tria->hnodes[analysis_counter]->deliverp();
+	tria->matice=(Matice*)tria->hmatice->delivers();
+	tria->matpar=(Matpar*)tria->hmatpar->delivers();
 	
 	return tria;
Index: /issm/trunk/src/c/objects/Elements/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/Penta.h	(revision 4396)
@@ -17,4 +17,5 @@
 class Matice;
 class Matpar;
+class Tria;
 
 #include "../../shared/Exceptions/exceptions.h"
@@ -185,5 +186,5 @@
 		void*	  SpawnBeam(int g0, int g1);
 		void*	  SpawnSing(int g0);
-		void*	  SpawnTria(int g0, int g1, int g2);
+		Tria*	  SpawnTria(int g0, int g1, int g2);
 		void	  SurfaceNormal(double* surface_normal, double xyz_list[3][3]);
 		void      UpdateFromDakota(void* inputs);
Index: /issm/trunk/src/c/objects/Elements/PentaHook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.cpp	(revision 4396)
@@ -25,16 +25,31 @@
 	numanalyses=UNDEF;
 	this->hnodes=NULL;
+	this->hmatice=NULL;
+	this->hmatpar=NULL;
+	this->hneighbors=NULL;
 }
 /*}}}*/
 /*FUNCTION PentaHook::~PentaHook(){{{1*/
 PentaHook::~PentaHook(){
+
+	int i;
+
+	for(i=0;i<this->numanalyses;i++){
+		delete this->hnodes[i];
+	}
 	delete [] this->hnodes;
+	delete hmatice;
+	delete hmatpar;
+	delete hneighbors;
 }
 /*}}}*/
-/*FUNCTION PentaHook::InitHookNodes(int numanalyses){{{1*/
-void PentaHook::InitHookNodes(int in_numanalyses){
-
+/*FUNCTION PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
+PentaHook::PentaHook(int in_numanalyses,int matice_id, int matpar_id){
+	
 	this->numanalyses=in_numanalyses;
-	this->hnodes=new Hook[in_numanalyses];
+	this->hnodes=new Hook*[in_numanalyses];
+	this->hmatice=new Hook(&matice_id,1);
+	this->hmatpar=new Hook(&matpar_id,1);
+	this->hneighbors=NULL; 
 
 }
@@ -42,21 +57,11 @@
 /*FUNCTION PentaHook::SetHookNodes(int* node_ids,int analysis_counter){{{1*/
 void PentaHook::SetHookNodes(int* node_ids,int analysis_counter){
-	this->hnodes[analysis_counter].Init(node_ids,6);
+	this->hnodes[analysis_counter]= new Hook(node_ids,6);
 
 }
 /*}}}*/
-/*FUNCTION PentaHook::InitHookMatice(int matice_id){{{1*/
-void PentaHook::InitHookMatice(int matice_id){
-	this->hmatice.Init(&matice_id,1);
-}
-
-/*FUNCTION PentaHook::InitHookMatpar(int matpar_id){{{1*/
-void PentaHook::InitHookMatpar(int matpar_id){
-	this->hmatpar.Init(&matpar_id,1);
-}
-
 /*FUNCTION PentaHook::InitHookNeighbors(int* element_ids){{{1*/
 void PentaHook::InitHookNeighbors(int* element_ids){
-	this->hneighbors.Init(element_ids,2);
+	this->hneighbors=new Hook(element_ids,2);
 
 }
@@ -69,14 +74,14 @@
 
 	triahook->numanalyses=this->numanalyses;
-	triahook->hnodes=new Hook[this->numanalyses];
+	triahook->hnodes=new Hook*[this->numanalyses];
 
 	for(i=0;i<this->numanalyses;i++){
 		/*Do not do anything if Hook is empty*/
-		if (this->hnodes[i].GetNum()==0) continue;
+		if (this->hnodes[i]->GetNum()==0) continue;
 		/*Else, spawn Hook*/
-		this->hnodes[i].Spawn(&triahook->hnodes[i],indices,3);
+		triahook->hnodes[i]=this->hnodes[i]->Spawn(indices,3);
 	}
-	triahook->hmatice.copy(&this->hmatice);
-	triahook->hmatpar.copy(&this->hmatpar);
+	triahook->hmatice=(Hook*)this->hmatice->copy();
+	triahook->hmatpar=(Hook*)this->hmatpar->copy();
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Elements/PentaHook.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/PentaHook.h	(revision 4396)
@@ -13,18 +13,16 @@
 	public: 
 		int   numanalyses; //number of analysis types
-		Hook* hnodes; // 6 nodes for each analysis type
-		Hook hmatice; // 1 ice material
-		Hook hmatpar; // 1 material parameter
-		Hook hneighbors; // 2 elements, first down, second up
+		Hook** hnodes; // 6 nodes for each analysis type
+		Hook*  hmatice; // 1 ice material
+		Hook*  hmatpar; // 1 material parameter
+		Hook*  hneighbors; // 2 elements, first down, second up
 
 		/*FUNCTION constructors, destructors {{{1*/
 		PentaHook();
+		PentaHook(int in_numanalyses,int matice_id, int matpar_id);
 		~PentaHook();
-		void InitHookNodes(int numanalyses);
 		void SetHookNodes(int* node_ids,int analysis_counter);
-		void InitHookMatice(int matice_id);
-		void InitHookMatpar(int matpar_id);
+		void SpawnTriaHook(TriaHook* triahook,int* indices);
 		void InitHookNeighbors(int* element_ids);
-		void SpawnTriaHook(TriaHook* triahook,int* indices);
 		/*}}}*/
 };
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4396)
@@ -23,4 +23,5 @@
 /*FUNCTION Tria::Tria(){{{1*/
 Tria::Tria(){
+
 	this->nodes=NULL;
 	this->matice=NULL;
@@ -39,23 +40,11 @@
 /*}}}*/
 /*FUNCTION Tria::Tria(int id, int index, IoModel* iomodel,int nummodels){{{1*/
-Tria::Tria(int tria_id, int index, IoModel* iomodel,int nummodels){ //i is the element index
-
-	int    i;
-	int    tria_matice_id;
-	int    tria_matpar_id;
-
+Tria::Tria(int tria_id, int index, IoModel* iomodel,int nummodels)
+
+	:TriaRef(P1Enum) //P1Enum: interpolation type
+	,TriaHook(nummodels,index+1,iomodel->numberofelements+1) //index+1: matice id, iomodel->numberofelements+1: matpar id
+                                                                  { //i is the element index
 	/*id: */
 	this->id=tria_id;
-
-	/*interpolation type: */
-	this->InitInterpolationType(P1Enum);
-	
-	/*hooks: */
-	tria_matice_id=index+1; //refers to the corresponding ice material object
-	tria_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
-
-	this->InitHookNodes(nummodels);      this->nodes=NULL;
-	this->InitHookMatice(tria_matice_id);this->matice=NULL;
-	this->InitHookMatpar(tria_matpar_id);this->matpar=NULL;
 
 	//this->parameters: we still can't point to it, it may not even exist. Configure will handle this.
@@ -66,4 +55,9 @@
 	this->results=new Results();
 
+	/*initialize pointers:*/
+	this->nodes=NULL;
+	this->matice=NULL;
+	this->matpar=NULL;
+
 }
 /*}}}*/
@@ -78,7 +72,16 @@
 	tria=new Tria();
 
-	/*copy fields: */
+	//deal with TriaRef mother class
+	tria->interpolation_type=this->interpolation_type;
+
+	//deal with TriaHook mother class
+	tria->numanalyses=this->numanalyses;
+	tria->hnodes=new Hook*[tria->numanalyses];
+	for(i=0;i<tria->numanalyses;i++)tria->hnodes[i]=(Hook*)this->hnodes[i]->copy();
+	tria->hmatice=(Hook*)this->hmatice->copy();
+	tria->hmatpar=(Hook*)this->hmatpar->copy();
+
+	/*deal with Tria fields: */
 	tria->id=this->id;
-	tria->interpolation_type=this->interpolation_type;
 	if(this->inputs){
 		tria->inputs=(Inputs*)this->inputs->Copy();
@@ -95,16 +98,10 @@
 	/*point parameters: */
 	tria->parameters=this->parameters;
-
-	/*now deal with hooks and objects: */
-	tria->InitHookNodes(this->numanalyses);
-	for(i=0;i<this->numanalyses;i++)tria->hnodes[i].copy(&this->hnodes[i]);
-	tria->hmatice.copy(&this->hmatice);
-	tria->hmatpar.copy(&this->hmatpar);
-
+	
 	/*recover objects: */
 	tria->nodes=(Node**)xmalloc(3*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
 	for(i=0;i<3;i++)tria->nodes[i]=this->nodes[i];
-	tria->matice=(Matice*)tria->hmatice.delivers();
-	tria->matpar=(Matpar*)tria->hmatpar.delivers();
+	tria->matice=(Matice*)tria->hmatice->delivers();
+	tria->matpar=(Matpar*)tria->hmatpar->delivers();
 
 	return tria;
@@ -159,10 +156,12 @@
 
 	/*allocate dynamic memory: */
-	InitHookNodes(numanalyses);
-
+	this->hnodes=new Hook*[this->numanalyses];
 	/*demarshall hooks: */
-	for(i=0;i<numanalyses;i++)hnodes[i].Demarshall(&marshalled_dataset);
-	hmatice.Demarshall(&marshalled_dataset);
-	hmatpar.Demarshall(&marshalled_dataset);
+	for(i=0;i<numanalyses;i++){
+		hnodes[i]=new Hook();
+		hnodes[i]->Demarshall(&marshalled_dataset);
+	}
+	hmatice=new Hook(); hmatice->Demarshall(&marshalled_dataset);
+	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
 
 	/*pointers are garbabe, until configuration is carried out: */
@@ -248,7 +247,7 @@
 
 	/*Marshall hooks: */
-	for(i=0;i<numanalyses;i++)hnodes[i].Marshall(&marshalled_dataset);
-	hmatice.Marshall(&marshalled_dataset);
-	hmatpar.Marshall(&marshalled_dataset);
+	for(i=0;i<numanalyses;i++)hnodes[i]->Marshall(&marshalled_dataset);
+	hmatice->Marshall(&marshalled_dataset);
+	hmatpar->Marshall(&marshalled_dataset);
 
 	/*Marshall inputs: */
@@ -279,5 +278,5 @@
 	int hnodes_size=0;;
 
-	for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i].MarshallSize();
+	for(i=0;i<numanalyses;i++)hnodes_size+=hnodes[i]->MarshallSize();
 
 	return sizeof(id)
@@ -285,6 +284,6 @@
 		+sizeof(interpolation_type)
 		+sizeof(numanalyses)
-		+hmatice.MarshallSize()
-		+hmatpar.MarshallSize()
+		+hmatice->MarshallSize()
+		+hmatpar->MarshallSize()
 		+inputs->MarshallSize()
 		+results->MarshallSize()
@@ -488,12 +487,12 @@
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	this->hnodes[analysis_counter].configure(nodesin);
-	this->hmatice.configure(materialsin);
-	this->hmatpar.configure(materialsin);
+	this->hnodes[analysis_counter]->configure(nodesin);
+	this->hmatice->configure(materialsin);
+	this->hmatpar->configure(materialsin);
 
 	/*Now, go pick up the objects inside the hooks: */
-	this->nodes=(Node**)this->hnodes[analysis_counter].deliverp();
-	this->matice=(Matice*)this->hmatice.delivers();
-	this->matpar=(Matpar*)this->hmatpar.delivers();
+	this->nodes=(Node**)this->hnodes[analysis_counter]->deliverp();
+	this->matice=(Matice*)this->hmatice->delivers();
+	this->matpar=(Matpar*)this->hmatpar->delivers();
 
 	/*point parameters to real dataset: */
Index: /issm/trunk/src/c/objects/Elements/TriaHook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaHook.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/TriaHook.cpp	(revision 4396)
@@ -25,16 +25,28 @@
 	numanalyses=UNDEF;
 	this->hnodes=NULL;
+	this->hmatice=NULL;
+	this->hmatpar=NULL;
 }
 /*}}}*/
 /*FUNCTION TriaHook::~TriaHook(){{{1*/
 TriaHook::~TriaHook(){
+	int i;
+
+	for(i=0;i<this->numanalyses;i++){
+		delete this->hnodes[i];
+	}
 	delete [] this->hnodes;
+	delete hmatice;
+	delete hmatpar;
+
 }
 /*}}}*/
-/*FUNCTION TriaHook::InitHookNodes(int numanalyses){{{1*/
-void TriaHook::InitHookNodes(int in_numanalyses){
-
+/*FUNCTION TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){{{1*/
+TriaHook::TriaHook(int in_numanalyses,int matice_id, int matpar_id){
+	
 	this->numanalyses=in_numanalyses;
-	this->hnodes=new Hook[in_numanalyses];
+	this->hnodes=new Hook*[in_numanalyses];
+	this->hmatice=new Hook(&matice_id,1);
+	this->hmatpar=new Hook(&matpar_id,1);
 
 }
@@ -42,16 +54,5 @@
 /*FUNCTION TriaHook::SetHookNodes(int* node_ids,int analysis_counter){{{1*/
 void TriaHook::SetHookNodes(int* node_ids,int analysis_counter){
-	this->hnodes[analysis_counter].Init(node_ids,3);
-
+	this->hnodes[analysis_counter]=new Hook(node_ids,3);
 }
 /*}}}*/
-/*FUNCTION TriaHook::InitHookMatice(int matice_id){{{1*/
-void TriaHook::InitHookMatice(int matice_id){
-	this->hmatice.Init(&matice_id,1);
-}
-
-/*FUNCTION TriaHook::InitHookMatpar(int matpar_id){{{1*/
-void TriaHook::InitHookMatpar(int matpar_id){
-	this->hmatpar.Init(&matpar_id,1);
-}
-
Index: /issm/trunk/src/c/objects/Elements/TriaHook.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaHook.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/TriaHook.h	(revision 4396)
@@ -11,19 +11,15 @@
 
 	public: 
-		int   numanalyses; //number of analysis types
-		Hook* hnodes; // 3 nodes for each analysis type
-		Hook hmatice; // 1 ice material
-		Hook hmatpar; // 1 material parameter
+		int    numanalyses; //number of analysis types
+		Hook** hnodes; // 3 nodes for each analysis type
+		Hook*  hmatice; // 1 ice material
+		Hook*  hmatpar; // 1 material parameter
 
 
 		/*FUNCTION constructors, destructors {{{1*/
 		TriaHook();
+		TriaHook(int in_numanalyses,int matice_id, int matpar_id);
 		~TriaHook();
-		void InitHookNodes(int numanalyses);
 		void SetHookNodes(int* node_ids,int analysis_counter);
-		void InitHookMatice(int matice_id);
-		void InitHookMatpar(int matpar_id);
-		void InitHookNeighbors(int* element_ids);
-
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/Elements/TriaRef.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaRef.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/TriaRef.cpp	(revision 4396)
@@ -25,11 +25,11 @@
 }
 /*}}}*/
+/*FUNCTION TriaRef::TriaRef(int type){{{1*/
+TriaRef::TriaRef(int type){
+	this->interpolation_type=type;
+}
+/*}}}*/
 /*FUNCTION TriaRef::~TriaRef(){{{1*/
 TriaRef::~TriaRef(){
 }
 /*}}}*/
-/*FUNCTION TriaRef::InitInterpolationType(int type){{{1*/
-void TriaRef::InitInterpolationType(int type){
-	this->interpolation_type=type;
-}
-/*}}}*/
Index: /issm/trunk/src/c/objects/Elements/TriaRef.h
===================================================================
--- /issm/trunk/src/c/objects/Elements/TriaRef.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Elements/TriaRef.h	(revision 4396)
@@ -16,6 +16,6 @@
 		/*FUNCTION constructors, destructors {{{1*/
 		TriaRef();
+		TriaRef(int type);
 		~TriaRef();
-		void InitInterpolationType(int type);
 		/*}}}*/
 		/*FUNCTION numerics {{{1*/
Index: /issm/trunk/src/c/objects/Hook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Hook.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Hook.cpp	(revision 4396)
@@ -31,9 +31,4 @@
 /*FUNCTION Hook::Hook(int* ids, int num){{{1*/
 Hook::Hook(int* in_ids, int in_num){
-	this->Init(in_ids,in_num);
-}
-/*}}}*/
-/*FUNCTION Hook::Init(int* ids, int num){{{1*/
-void Hook::Init(int* in_ids, int in_num){
 
 	/*Intermediaries*/
@@ -62,43 +57,4 @@
 			this->offsets[i]=0;
 		}
-	}
-}
-/*}}}*/
-/*FUNCTION Hook::Hook(Object** hook_objects, int* hook_ids, int* hook_offsets,int hook_num){{{1*/
-Hook::Hook(Object** hook_objects, int* hook_ids, int* hook_offsets,int hook_num){
-
-	/*just plug in: */
-	this->num=hook_num;
-	this->objects=hook_objects;
-	this->offsets=hook_offsets;
-	this->ids=hook_ids;
-
-}
-/*}}}*/
-/*FUNCTION Hook::Hook(Hook* input) {{{1*/
-Hook::Hook(Hook* input){
-
-	int i;
-	Object** input_objects=NULL;
-	int*     input_ids=NULL;
-	int*     input_offsets=NULL;
-
-	/*get internals of input: */
-	this->num=input->GetNum();
-	input_objects=input->GetObjects();
-	input_ids=input->Ids();
-	input_offsets=input->GetOffsets();
-
-	if(this->num){
-		this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
-		this->ids=(int*)xmalloc(this->num*sizeof(int));
-		this->offsets=(int*)xmalloc(this->num*sizeof(int));
-	}
-	
-
-	for(i=0;i<this->num;i++){
-		this->objects[i]=input_objects[i];
-		this->offsets[i]=input_offsets[i];
-		this->ids[i]=input_ids[i];
 	}
 }
@@ -252,29 +208,27 @@
 }
 /*}}}*/
-/*FUNCTION Hook::copy(Hook* input) {{{1*/
-void Hook::copy(Hook* input){
-
-	int i;
-	Object** input_objects=NULL;
-	int*     input_ids=NULL;
-	int*     input_offsets=NULL;
-
-	/*get internals of input: */
-	this->num=input->GetNum();
-	input_objects=input->GetObjects();
-	input_ids=input->Ids();
-	input_offsets=input->GetOffsets();
-
-	if(this->num){
-		this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
-		this->ids=(int*)xmalloc(this->num*sizeof(int));
-		this->offsets=(int*)xmalloc(this->num*sizeof(int));
-	}
-	
-
-	for(i=0;i<this->num;i++){
-		this->objects[i]=input_objects[i];
-		this->offsets[i]=input_offsets[i];
-		this->ids[i]=input_ids[i];
+/*FUNCTION Hook::copy(void) {{{1*/
+Object* Hook::copy(void){
+
+	int i;
+
+	/*output: */
+	Hook* output=NULL;
+
+	/*initalize output: */
+	output=new Hook();
+
+	/*copy in the fields: */
+	output->num=this->num;
+	if(output->num){
+		output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
+		output->ids=(int*)xmalloc(output->num*sizeof(int));
+		output->offsets=(int*)xmalloc(output->num*sizeof(int));
+	}
+	
+	for(i=0;i<output->num;i++){
+		output->objects[i]=this->objects[i];
+		output->offsets[i]=this->offsets[i];
+		output->ids[i]=this->ids[i];
 	}
 }
@@ -363,12 +317,18 @@
 /*}}}*/
 /*FUNCTION Hook::Spawn{{{1*/
-void Hook::Spawn(Hook* spawnedhook, int* indices, int numindices){
-
-	int i;
+Hook* Hook::Spawn(int* indices, int numindices){
+
+	int i;
+
+	/*output: */
+	Hook* output=NULL;
+
+	/*allocate: */
+	output=new Hook();
 
 	/*If this Hook is empty, simply return*/
 	if(this->num==0){
-		spawnedhook->num=0;
-		return;
+		output->num=0;
+		return output;
 	}
 
@@ -377,16 +337,18 @@
 
 	/*go pickup the correct objects, ids and offsets :*/
-	spawnedhook->num=numindices;
-	if(spawnedhook->num<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
-
-	spawnedhook->objects=(Object**)xmalloc(spawnedhook->num*sizeof(Object*));
-	spawnedhook->ids=(int*)xmalloc(spawnedhook->num*sizeof(int));
-	spawnedhook->offsets=(int*)xmalloc(spawnedhook->num*sizeof(int));
-
-	for(i=0;i<spawnedhook->num;i++){
-		spawnedhook->objects[i]=this->objects[indices[i]];
-		spawnedhook->ids[i]=this->ids[indices[i]];
-		spawnedhook->offsets[i]=this->offsets[indices[i]];
-	}
-}
-/*}}}*/
+	output->num=numindices;
+	if(output->num<1) ISSMERROR("Trying to spawn an empty ElementProperties!");
+
+	output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
+	output->ids=(int*)xmalloc(output->num*sizeof(int));
+	output->offsets=(int*)xmalloc(output->num*sizeof(int));
+
+	for(i=0;i<output->num;i++){
+		output->objects[i]=this->objects[indices[i]];
+		output->ids[i]=this->ids[indices[i]];
+		output->offsets[i]=this->offsets[indices[i]];
+	}
+
+	return output;
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Hook.h
===================================================================
--- /issm/trunk/src/c/objects/Hook.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Hook.h	(revision 4396)
@@ -29,7 +29,4 @@
 		Hook();
 		Hook(int* ids, int num);
-		void Init(int* ids, int num);
-		Hook(Object** objects, int* ids, int* offsets,int num);
-		Hook(Hook* hook);
 		~Hook();
 		/*}}}*/
@@ -40,5 +37,5 @@
 		int        MarshallSize();
 		void       Demarshall(char** pmarshalled_dataset);
-		void       copy(Hook* hook);
+		Object*    copy(void);
 		/*}}}*/
 		/*Hook management: {{{1*/
@@ -46,5 +43,5 @@
 		Object**   deliverp(void); //deliver all objects
 		void       configure(DataSet* dataset);
-		void       Spawn(Hook* spawnedhook, int* indices, int numindices);
+		Hook*      Spawn(int* indices, int numindices);
 		Object**   GetObjects(void);
 		int*       Ids(void);
Index: /issm/trunk/src/c/objects/Loads/Icefront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Icefront.cpp	(revision 4396)
@@ -24,4 +24,7 @@
 	this->inputs=NULL;
 	this->parameters=NULL;
+	this->hnodes=NULL;
+	this->helement=NULL;
+	this->hmatpar=NULL;
 }
 /*}}}*/
@@ -84,7 +87,7 @@
 
 	/*Hooks: */
-	this->hnodes.Init(icefront_node_ids,num_nodes);
-	this->helement.Init(&icefront_eid,1);
-	this->hmatpar.Init(&icefront_mparid,1);
+	this->hnodes=new Hook(icefront_node_ids,num_nodes);
+	this->helement=new Hook(&icefront_eid,1);
+	this->hmatpar=new Hook(&icefront_mparid,1);
 
 	//intialize  and add as many inputs per element as requested: 
@@ -103,4 +106,7 @@
 	delete inputs;
 	this->parameters=NULL;
+	delete hnodes;
+	delete helement;
+	delete hmatpar;
 }
 /*}}}*/
@@ -112,7 +118,7 @@
 	printf("   id: %i\n",id);
 	printf("   analysis_type: %s\n",EnumAsString(analysis_type));
-	hnodes.Echo();
-	helement.Echo();
-	hmatpar.Echo();
+	hnodes->Echo();
+	helement->Echo();
+	hmatpar->Echo();
 	printf("   parameters\n");
 	parameters->Echo();
@@ -127,7 +133,7 @@
 	printf("   id: %i\n",id);
 	printf("   analysis_type: %s\n",EnumAsString(analysis_type));
-	hnodes.DeepEcho();
-	helement.DeepEcho();
-	hmatpar.DeepEcho();
+	hnodes->DeepEcho();
+	helement->DeepEcho();
+	hmatpar->DeepEcho();
 	printf("   parameters\n");
 	parameters->DeepEcho();
@@ -167,7 +173,7 @@
 
 	/*Marshall hooks: */
-	hnodes.Marshall(&marshalled_dataset);
-	helement.Marshall(&marshalled_dataset);
-	hmatpar.Marshall(&marshalled_dataset);
+	hnodes->Marshall(&marshalled_dataset);
+	helement->Marshall(&marshalled_dataset);
+	hmatpar->Marshall(&marshalled_dataset);
 
 	/*Marshall inputs: */
@@ -189,7 +195,7 @@
 	return sizeof(id)
 		+sizeof(analysis_type)
-		+hnodes.MarshallSize()
-		+helement.MarshallSize()
-		+hmatpar.MarshallSize()
+		+hnodes->MarshallSize()
+		+helement->MarshallSize()
+		+hmatpar->MarshallSize()
 		+inputs->MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
@@ -211,7 +217,7 @@
 
 	/*demarshall hooks: */
-	hnodes.Demarshall(&marshalled_dataset);
-	helement.Demarshall(&marshalled_dataset);
-	hmatpar.Demarshall(&marshalled_dataset);
+	hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
+	helement=new Hook(); helement->Demarshall(&marshalled_dataset);
+	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
 	
 	/*demarshall inputs: */
@@ -253,7 +259,7 @@
 
 	/*now deal with hooks and objects: */
-	icefront->hnodes.copy(&this->hnodes);
-	icefront->helement.copy(&this->helement);
-	icefront->hmatpar.copy(&this->hmatpar);
+	icefront->hnodes=(Hook*)this->hnodes->copy();
+	icefront->helement=(Hook*)this->helement->copy();
+	icefront->hmatpar=(Hook*)this->hmatpar->copy();
 
 	return icefront;
@@ -268,7 +274,7 @@
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	hnodes.configure(nodesin);
-	helement.configure(elementsin);
-	hmatpar.configure(materialsin);
+	hnodes->configure(nodesin);
+	helement->configure(elementsin);
+	hmatpar->configure(materialsin);
 
 	/*point parameters to real dataset: */
@@ -411,7 +417,7 @@
 
 	/*Recover hook objects: */
-	matpar=(Matpar*)hmatpar.delivers();
-	element=(Element*)helement.delivers();
-	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar->delivers();
+	element=(Element*)helement->delivers();
+	nodes=(Node**)hnodes->deliverp();
 
 	element_type=element->Enum();
@@ -514,7 +520,7 @@
 
 	/*Recover hook objects: */
-	matpar=(Matpar*)hmatpar.delivers();
-	element=(Element*)helement.delivers();
-	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar->delivers();
+	element=(Element*)helement->delivers();
+	nodes=(Node**)hnodes->deliverp();
 
 	element_type=element->Enum();
@@ -653,7 +659,7 @@
 
 	/*Recover hook objects: */
-	matpar=(Matpar*)hmatpar.delivers();
-	element=(Element*)helement.delivers();
-	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar->delivers();
+	element=(Element*)helement->delivers();
+	nodes=(Node**)hnodes->deliverp();
 	
 	/*check icefront is associated to a pentaelem: */
@@ -756,5 +762,5 @@
 
 	Node**   nodes=NULL;
-	nodes=(Node**)hnodes.deliverp();
+	nodes=(Node**)hnodes->deliverp();
 	inputs->GetParameterValue(&type,TypeEnum);
 	
Index: /issm/trunk/src/c/objects/Loads/Icefront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Icefront.h	(revision 4396)
@@ -25,7 +25,7 @@
 
 		/*hooks: */
-		Hook hnodes;
-		Hook helement;
-		Hook hmatpar;
+		Hook* hnodes;
+		Hook* helement;
+		Hook* hmatpar;
 
 		/*inputs and parameters: */
Index: /issm/trunk/src/c/objects/Loads/Numericalflux.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Numericalflux.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Numericalflux.cpp	(revision 4396)
@@ -23,4 +23,6 @@
 	this->inputs=NULL;
 	this->parameters=NULL;
+	this->helements=NULL;
+	this->hnodes=NULL;
 }
 /*}}}*/
@@ -109,6 +111,6 @@
 
 	/*Hooks: */
-	this->hnodes.Init(numericalflux_node_ids,num_nodes);
-	this->helements.Init(numericalflux_elem_ids,num_elems);
+	this->hnodes=new Hook(numericalflux_node_ids,num_nodes);
+	this->helements=new Hook(numericalflux_elem_ids,num_elems);
 
 	//intialize  and add as many inputs per element as requested: 
@@ -124,4 +126,6 @@
 	delete inputs;
 	this->parameters=NULL;
+	delete helements;
+	delete hnodes;
 }
 /*}}}*/
@@ -139,6 +143,6 @@
 	printf("   id: %i\n",id);
 	printf("   analysis_type: %s\n",EnumAsString(analysis_type));
-	hnodes.DeepEcho();
-	helements.DeepEcho();
+	hnodes->DeepEcho();
+	helements->DeepEcho();
 	printf("   parameters\n");
 	parameters->DeepEcho();
@@ -181,6 +185,6 @@
 
 	/*Marshall hooks: */
-	hnodes.Marshall(&marshalled_dataset);
-	helements.Marshall(&marshalled_dataset);
+	hnodes->Marshall(&marshalled_dataset);
+	helements->Marshall(&marshalled_dataset);
 
 	/*Marshall inputs: */
@@ -203,6 +207,6 @@
 	return sizeof(id)
 		+sizeof(analysis_type)
-		+hnodes.MarshallSize()
-		+helements.MarshallSize()
+		+hnodes->MarshallSize()
+		+helements->MarshallSize()
 		+inputs->MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
@@ -224,6 +228,6 @@
 
 	/*demarshall hooks: */
-	hnodes.Demarshall(&marshalled_dataset);
-	helements.Demarshall(&marshalled_dataset);
+	hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
+	helements=new Hook(); helements->Demarshall(&marshalled_dataset);
 	
 	/*demarshall inputs: */
@@ -265,6 +269,6 @@
 
 	/*now deal with hooks and objects: */
-	numericalflux->hnodes.copy(&this->hnodes);
-	numericalflux->helements.copy(&this->helements);
+	numericalflux->hnodes=(Hook*)this->hnodes->copy();
+	numericalflux->helements=(Hook*)this->helements->copy();
 
 	return numericalflux;
@@ -279,6 +283,6 @@
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	hnodes.configure(nodesin);
-	helements.configure(elementsin);
+	hnodes->configure(nodesin);
+	helements->configure(elementsin);
 
 	/*point parameters to real dataset: */
@@ -394,6 +398,6 @@
 
 	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	trias=(Tria**)helements.deliverp();
+	nodes=(Node**)hnodes->deliverp();
+	trias=(Tria**)helements->deliverp();
 
 	/*recover parameters: */
@@ -514,6 +518,6 @@
 
 	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	trias=(Tria**)helements.deliverp();
+	nodes=(Node**)hnodes->deliverp();
+	trias=(Tria**)helements->deliverp();
 
 	/*recover parameters: */
@@ -640,6 +644,6 @@
 
 	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
-	trias=(Tria**)helements.deliverp();
+	nodes=(Node**)hnodes->deliverp();
+	trias=(Tria**)helements->deliverp();
 
 	/*Retrieve parameters: */
@@ -742,5 +746,5 @@
 
 	/*recover objects from hooks: */
-	nodes=(Node**)hnodes.deliverp();
+	nodes=(Node**)hnodes->deliverp();
 	
 	/*recover type: */
Index: /issm/trunk/src/c/objects/Loads/Numericalflux.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Numericalflux.h	(revision 4396)
@@ -22,6 +22,6 @@
 		int analysis_type;
 
-		Hook        helements;
-		Hook        hnodes;
+		Hook*       helements;
+		Hook*       hnodes;
 		Parameters *parameters;
 		Inputs     *inputs;
Index: /issm/trunk/src/c/objects/Loads/Pengrid.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Pengrid.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Pengrid.cpp	(revision 4396)
@@ -23,4 +23,7 @@
 	this->inputs=NULL;
 	this->parameters=NULL;
+	this->hnode=NULL;
+	this->helement=NULL;
+	this->hmatpar=NULL;
 	
 	/*not active, not zigzagging: */
@@ -51,7 +54,7 @@
 	pengrid_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
 
-	this->hnode.Init(&pengrid_node_id,1);
-	this->helement.Init(&pengrid_element_id,1);
-	this->hmatpar.Init(&pengrid_matpar_id,1);
+	this->hnode=new Hook(&pengrid_node_id,1);
+	this->helement=new Hook(&pengrid_element_id,1);
+	this->hmatpar=new Hook(&pengrid_matpar_id,1);
 
 	//initialize inputs: none needed
@@ -69,4 +72,7 @@
 /*FUNCTION Pengrid::destructor {{{1*/
 Pengrid::~Pengrid(){
+	delete hnode;
+	delete helement;
+	delete hmatpar;
 	return;
 }
@@ -85,7 +91,7 @@
 	printf("   id: %i\n",id);
 	printf("   analysis_type: %s\n",EnumAsString(analysis_type));
-	hnode.DeepEcho();
-	helement.DeepEcho();
-	hmatpar.DeepEcho();
+	hnode->DeepEcho();
+	helement->DeepEcho();
+	hmatpar->DeepEcho();
 	printf("   active %i\n",this->active);
 	printf("   zigzag_counter %i\n",this->zigzag_counter);
@@ -129,7 +135,7 @@
 
 	/*Marshall hooks: */
-	hnode.Marshall(&marshalled_dataset);
-	helement.Marshall(&marshalled_dataset);
-	hmatpar.Marshall(&marshalled_dataset);
+	hnode->Marshall(&marshalled_dataset);
+	helement->Marshall(&marshalled_dataset);
+	hmatpar->Marshall(&marshalled_dataset);
 
 	/*Marshall inputs: */
@@ -154,7 +160,7 @@
 		+sizeof(active)
 		+sizeof(zigzag_counter)
-		+hnode.MarshallSize()
-		+helement.MarshallSize()
-		+hmatpar.MarshallSize()
+		+hnode->MarshallSize()
+		+helement->MarshallSize()
+		+hmatpar->MarshallSize()
 		+inputs->MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
@@ -179,7 +185,7 @@
 
 	/*demarshall hooks: */
-	hnode.Demarshall(&marshalled_dataset);
-	helement.Demarshall(&marshalled_dataset);
-	hmatpar.Demarshall(&marshalled_dataset);
+	hnode=new Hook(); hnode->Demarshall(&marshalled_dataset);
+	helement=new Hook(); helement->Demarshall(&marshalled_dataset);
+	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
 	
 	/*demarshall inputs: */
@@ -220,7 +226,7 @@
 
 	/*now deal with hooks and objects: */
-	pengrid->hnode.copy(&this->hnode);
-	pengrid->helement.copy(&this->helement);
-	pengrid->hmatpar.copy(&this->hmatpar);
+	pengrid->hnode=(Hook*)this->hnode->copy();
+	pengrid->hmatpar=(Hook*)this->hmatpar->copy();
+	pengrid->helement=(Hook*)this->helement->copy();
 
 	//let's not forget internals
@@ -239,7 +245,7 @@
 	/*Take care of hooking up all objects for this load, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	hnode.configure(nodesin);
-	helement.configure(elementsin);
-	hmatpar.configure(materialsin);
+	hnode->configure(nodesin);
+	helement->configure(elementsin);
+	hmatpar->configure(materialsin);
 
 	/*point parameters to real dataset: */
@@ -381,5 +387,5 @@
 
 	/*recover objects from hooks: */
-	node=(Node*)hnode.delivers();
+	node=(Node*)hnode->delivers();
 	
 	node->GetDofList(&doflist_per_node[0],&numberofdofspernode);
@@ -448,7 +454,7 @@
 
 	/*recover pointers: */
-	node=(Node*)hnode.delivers();
-	penta=(Penta*)helement.delivers();
-	matpar=(Matpar*)hmatpar.delivers();
+	node=(Node*)hnode->delivers();
+	penta=(Penta*)helement->delivers();
+	matpar=(Matpar*)hmatpar->delivers();
 	
 	/*check that pengrid is not a clone (penalty to be added only once)*/
@@ -533,6 +539,6 @@
 
 	/*recover pointers: */
-	node=(Node*)hnode.delivers();
-	penta=(Penta*)helement.delivers();
+	node=(Node*)hnode->delivers();
+	penta=(Penta*)helement->delivers();
 
 	//recover slope: */
@@ -577,7 +583,7 @@
 
 	/*recover pointers: */
-	node=(Node*)hnode.delivers();
-	penta=(Penta*)helement.delivers();
-	matpar=(Matpar*)hmatpar.delivers();
+	node=(Node*)hnode->delivers();
+	penta=(Penta*)helement->delivers();
+	matpar=(Matpar*)hmatpar->delivers();
 
 	/*check that pengrid is not a clone (penalty to be added only once)*/
@@ -665,7 +671,7 @@
 
 	/*recover pointers: */
-	node=(Node*)hnode.delivers();
-	penta=(Penta*)helement.delivers();
-	matpar=(Matpar*)hmatpar.delivers();
+	node=(Node*)hnode->delivers();
+	penta=(Penta*)helement->delivers();
+	matpar=(Matpar*)hmatpar->delivers();
 
 	/*check that pengrid is not a clone (penalty to be added only once)*/
@@ -738,7 +744,7 @@
 
 	/*recover pointers: */
-	node=(Node*)hnode.delivers();
-	penta=(Penta*)helement.delivers();
-	matpar=(Matpar*)hmatpar.delivers();
+	node=(Node*)hnode->delivers();
+	penta=(Penta*)helement->delivers();
+	matpar=(Matpar*)hmatpar->delivers();
 
 	if(!this->active)return;
Index: /issm/trunk/src/c/objects/Loads/Pengrid.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Pengrid.h	(revision 4396)
@@ -21,7 +21,7 @@
 		int analysis_type;
 		
-		Hook hnode;  //hook to 1 node
-		Hook helement;  //hook to 1 element
-		Hook hmatpar; //hook to 1 matpar
+		Hook* hnode;  //hook to 1 node
+		Hook* helement;  //hook to 1 element
+		Hook* hmatpar; //hook to 1 matpar
 
 		Parameters* parameters; //pointer to solution parameters
Index: /issm/trunk/src/c/objects/Loads/Penpair.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Penpair.cpp	(revision 4396)
@@ -20,27 +20,27 @@
 /*FUNCTION Penpair::constructor {{{1*/
 Penpair::Penpair(){
+
+	this->hnodes=NULL;
 	return;
 }
 /*}}}1*/
 /*FUNCTION Penpair::creation {{{1*/
-Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type):
-	hnodes(penpair_node_ids,2)
-{
+Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){
+
+	
+	this->id=penpair_id;
+	this->analysis_type=in_analysis_type;
+	this->hnodes=new Hook(penpair_node_ids,2);
+	
+	return;
+}
+/*}}}1*/
+/*FUNCTION Penpair::creation {{{1*/
+Penpair::Penpair(int penpair_id, Hook* penpair_hnodes,int in_analysis_type){
 
 	/*all the initialization has been done by the initializer, just fill in the id: */
 	this->id=penpair_id;
 	this->analysis_type=in_analysis_type;
-	
-	return;
-}
-/*}}}1*/
-/*FUNCTION Penpair::creation {{{1*/
-Penpair::Penpair(int penpair_id, Hook* penpair_hnodes,int in_analysis_type):
-	hnodes(penpair_hnodes)
-{
-
-	/*all the initialization has been done by the initializer, just fill in the id: */
-	this->id=penpair_id;
-	this->analysis_type=in_analysis_type;
+	this->hnodes=penpair_hnodes;
 	
 	return;
@@ -49,4 +49,5 @@
 /*FUNCTION Penpair::destructor {{{1*/
 Penpair::~Penpair(){
+	delete hnodes;
 	return;
 }
@@ -62,5 +63,5 @@
 	printf("   id: %i\n",id);
 	printf("   analysis_type: %s\n",EnumAsString(analysis_type));
-	hnodes.Echo();
+	hnodes->Echo();
 	
 	return;
@@ -73,5 +74,5 @@
 	printf("   id: %i\n",id);
 	printf("   analysis_type: %s\n",EnumAsString(analysis_type));
-	hnodes.DeepEcho();
+	hnodes->DeepEcho();
 
 	return;
@@ -107,5 +108,5 @@
 
 	/*Marshall hooks*/
-	hnodes.Marshall(&marshalled_dataset);
+	hnodes->Marshall(&marshalled_dataset);
 
 	*pmarshalled_dataset=marshalled_dataset;
@@ -118,5 +119,5 @@
 	return sizeof(id)+
 		+sizeof(analysis_type)
-		+hnodes.MarshallSize()
+		+hnodes->MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
 }
@@ -137,5 +138,5 @@
 
 	/*demarshall hooks: */
-	hnodes.Demarshall(&marshalled_dataset);
+	hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
 
 	/*return: */
@@ -162,5 +163,5 @@
 
 	/*now deal with hooks and objects: */
-	penpair->hnodes.copy(&this->hnodes);
+	penpair->hnodes=(Hook*)this->hnodes->copy();
 
 	return penpair;
@@ -175,5 +176,5 @@
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	hnodes.configure(nodesin);
+	hnodes->configure(nodesin);
 
 }
Index: /issm/trunk/src/c/objects/Loads/Penpair.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Penpair.h	(revision 4396)
@@ -20,5 +20,5 @@
 		int analysis_type;
 		
-		Hook hnodes;  //hook to 2 nodes
+		Hook* hnodes;  //hook to 2 nodes
 
 	public:
Index: /issm/trunk/src/c/objects/Loads/Riftfront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.cpp	(revision 4396)
@@ -25,4 +25,7 @@
 	this->inputs=NULL;
 	this->parameters=NULL;
+	this->hnodes=NULL;
+	this->helements=NULL;
+	this->hmatpar=NULL;
 }
 /*}}}*/
@@ -59,6 +62,6 @@
 	riftfront_matpar_id=iomodel->numberofelements+1; //matlab indexing
 
-	this->hnodes.Init(riftfront_node_ids,2);
-	this->hmatpar.Init(&riftfront_matpar_id,1);
+	this->hnodes=new Hook(riftfront_node_ids,2);
+	this->hmatpar=new Hook(&riftfront_matpar_id,1);
 
 	/*computational parameters: */
@@ -98,4 +101,7 @@
 	delete inputs;
 	this->parameters=NULL;
+	delete hnodes;
+	delete hmatpar;
+	delete helements;
 }
 /*}}}*/
@@ -113,6 +119,6 @@
 	printf("   id: %i\n",id);
 	printf("   analysis_type: %s\n",EnumAsString(analysis_type));
-	hnodes.DeepEcho();
-	hmatpar.DeepEcho();
+	hnodes->DeepEcho();
+	hmatpar->DeepEcho();
 	printf("   parameters\n");
 	parameters->DeepEcho();
@@ -161,6 +167,6 @@
 
 	/*Marshall hooks: */
-	hnodes.Marshall(&marshalled_dataset);
-	hmatpar.Marshall(&marshalled_dataset);
+	hnodes->Marshall(&marshalled_dataset);
+	hmatpar->Marshall(&marshalled_dataset);
 
 	/*Marshall inputs: */
@@ -192,6 +198,6 @@
 		+sizeof(prestable)
 		+sizeof(penalty_lock)
-		+hnodes.MarshallSize()
-		+hmatpar.MarshallSize()
+		+hnodes->MarshallSize()
+		+hmatpar->MarshallSize()
 		+inputs->MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
@@ -224,6 +230,6 @@
 
 	/*demarshall hooks: */
-	hnodes.Demarshall(&marshalled_dataset);
-	hmatpar.Demarshall(&marshalled_dataset);
+	hnodes=new Hook(); hnodes->Demarshall(&marshalled_dataset);
+	hmatpar=new Hook(); hmatpar->Demarshall(&marshalled_dataset);
 	
 	/*demarshall inputs: */
@@ -264,7 +270,6 @@
 
 	/*now deal with hooks and objects: */
-	riftfront->hnodes.copy(&this->hnodes);
-	riftfront->helements.copy(&this->helements);
-	riftfront->hmatpar.copy(&this->hmatpar);
+	riftfront->hnodes=(Hook*)this->hnodes->copy();
+	riftfront->hmatpar=(Hook*)this->hmatpar->copy();
 
 	return riftfront;
@@ -279,6 +284,6 @@
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	hnodes.configure(nodesin);
-	hmatpar.configure(materialsin);
+	hnodes->configure(nodesin);
+	hmatpar->configure(materialsin);
 
 	/*point parameters to real dataset: */
@@ -320,6 +325,6 @@
 
 	/*Recover hook objects: */
-	elements=(Element**)helements.deliverp();
-	nodes=(Node**)hnodes.deliverp();
+	elements=(Element**)helements->deliverp();
+	nodes=(Node**)hnodes->deliverp();
 
 	/*enum of element? */
@@ -444,7 +449,7 @@
 	
 	/*Recover hook objects: */
-	elements=(Element**)helements.deliverp();
-	nodes=(Node**)hnodes.deliverp();
-	matpar=(Matpar*)hmatpar.delivers();
+	elements=(Element**)helements->deliverp();
+	nodes=(Node**)hnodes->deliverp();
+	matpar=(Matpar*)hmatpar->delivers();
 
 	/*enum of element? */
@@ -569,6 +574,6 @@
 
 	/*Recover hook objects: */
-	elements=(Element**)helements.deliverp();
-	nodes=(Node**)hnodes.deliverp();
+	elements=(Element**)helements->deliverp();
+	nodes=(Node**)hnodes->deliverp();
 
 	/*enum of element? */
@@ -647,5 +652,5 @@
 	Node      **nodes           = NULL;
 	
-	nodes=(Node**)hnodes.deliverp();
+	nodes=(Node**)hnodes->deliverp();
 
 	for(i=0;i<MAX_RIFTFRONT_GRIDS;i++){
@@ -705,6 +710,6 @@
 
 	/*Recover hook objects: */
-	elements=(Element**)helements.deliverp();
-	nodes=(Node**)hnodes.deliverp();
+	elements=(Element**)helements->deliverp();
+	nodes=(Node**)hnodes->deliverp();
 
 	/*enum of element? */
@@ -770,6 +775,6 @@
 
 	/*Recover hook objects: */
-	elements=(Element**)helements.deliverp();
-	nodes=(Node**)hnodes.deliverp();
+	elements=(Element**)helements->deliverp();
+	nodes=(Node**)hnodes->deliverp();
 
 	/*enum of element? */
@@ -820,6 +825,6 @@
 
 	/*Recover hook objects: */
-	elements=(Element**)helements.deliverp();
-	nodes=(Node**)hnodes.deliverp();
+	elements=(Element**)helements->deliverp();
+	nodes=(Node**)hnodes->deliverp();
 
 	/*enum of element? */
@@ -876,6 +881,6 @@
 
 	/*Recover hook objects: */
-	elements=(Element**)helements.deliverp();
-	nodes=(Node**)hnodes.deliverp();
+	elements=(Element**)helements->deliverp();
+	nodes=(Node**)hnodes->deliverp();
 
 	/*enum of element? */
Index: /issm/trunk/src/c/objects/Loads/Riftfront.h
===================================================================
--- /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Loads/Riftfront.h	(revision 4396)
@@ -24,7 +24,7 @@
 		int     analysis_type;
 
-		Hook hnodes; //2 nodes
-		Hook helements; //2 elements
-		Hook hmatpar;
+		Hook* hnodes; //2 nodes
+		Hook* helements; //2 elements
+		Hook* hmatpar;
 		
 		/*computational: */
Index: /issm/trunk/src/c/objects/Node.cpp
===================================================================
--- /issm/trunk/src/c/objects/Node.cpp	(revision 4395)
+++ /issm/trunk/src/c/objects/Node.cpp	(revision 4396)
@@ -22,4 +22,6 @@
 Node::Node(){
 	this->inputs=NULL;
+	this->hvertex=NULL;
+	this->hupper_node=NULL;
 	return;
 }
@@ -27,11 +29,13 @@
 /*FUNCTION Node::Node(int id, int vertex_id, int uppernode_id, int numdofs, NodeProperties*) {{{2*/
 Node::Node(int node_id,int node_sid, int node_vertex_id, int node_upper_node_id, int node_numdofs):
-	indexing(node_numdofs),
-    hvertex(&node_vertex_id,1),
-    hupper_node(&node_upper_node_id,1){
+	indexing(node_numdofs){
 
 	this->id=node_id;
 	this->sid=node_sid;
 	this->inputs=new Inputs();
+	
+	this->hvertex=new Hook(&node_vertex_id,1);
+    this->hupper_node=new Hook(&node_upper_node_id,1);
+
 }
 /*}}}*/
@@ -86,6 +90,6 @@
 	}
 
-	this->hvertex.Init(&vertex_id,1); //node id is the same as the vertex id, continuous galerkin!
-	this->hupper_node.Init(&upper_node_id,1);
+	this->hvertex=new Hook(&vertex_id,1); //node id is the same as the vertex id, continuous galerkin!
+	this->hupper_node=new Hook(&upper_node_id,1);
 
 	//intialize inputs, and add as many inputs per element as requested: 
@@ -201,8 +205,8 @@
 	indexing.DeepEcho();
 	printf("Vertex:\n");
-	hvertex.DeepEcho();
+	hvertex->DeepEcho();
 	printf("Upper node:\n");
 	//Do not Deepecho the upper_node otherwise DeepEcho will go crazy!
-	hupper_node.Echo();
+	hupper_node->Echo();
 	printf("   inputs\n");
 	inputs->DeepEcho();
@@ -244,6 +248,6 @@
 	/*marshall objects: */
 	indexing.Marshall(&marshalled_dataset);
-	hvertex.Marshall(&marshalled_dataset);
-	hupper_node.Marshall(&marshalled_dataset);
+	hvertex->Marshall(&marshalled_dataset);
+	hupper_node->Marshall(&marshalled_dataset);
 
 	/*Marshall inputs: */
@@ -266,6 +270,6 @@
 		sizeof(sid)+
 		indexing.MarshallSize()+
-		hvertex.MarshallSize()+
-		hupper_node.MarshallSize()+
+		hvertex->MarshallSize()+
+		hupper_node->MarshallSize()+
 		inputs->MarshallSize()+
 		sizeof(analysis_type)+
@@ -290,6 +294,6 @@
 	/*demarshall objects: */
 	indexing.Demarshall(&marshalled_dataset);
-	hvertex.Demarshall(&marshalled_dataset);
-	hupper_node.Demarshall(&marshalled_dataset);
+	hvertex=new Hook(); hvertex->Demarshall(&marshalled_dataset);
+	hupper_node=new Hook(); hupper_node->Demarshall(&marshalled_dataset);
 
 	/*demarshall inputs: */
@@ -311,5 +315,5 @@
 Object* Node::copy() {
 		
-	return new Node(this->id,this->sid,&this->indexing, &this->hvertex,&this->hupper_node,this->inputs,this->analysis_type);
+	return new Node(this->id,this->sid,&this->indexing, this->hvertex,this->hupper_node,this->inputs,this->analysis_type);
 
 }
@@ -325,6 +329,6 @@
 	/*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 
 	 * datasets, using internal ids and offsets hidden in hooks: */
-	hvertex.configure(verticesin);
-	hupper_node.configure(nodesin);
+	hvertex->configure(verticesin);
+	hupper_node->configure(nodesin);
 
 }
@@ -341,5 +345,5 @@
 	Vertex* vertex=NULL;
 
-	vertex=(Vertex*)this->hvertex.delivers();
+	vertex=(Vertex*)this->hvertex->delivers();
 
 	return vertex->dof;
@@ -365,5 +369,5 @@
 	Vertex*  vertex=NULL;
 
-	vertex=(Vertex*)hvertex.delivers();
+	vertex=(Vertex*)hvertex->delivers();
 	return vertex->id;
 }
@@ -374,5 +378,5 @@
 	Vertex*  vertex=NULL;
 
-	vertex=(Vertex*)hvertex.delivers();
+	vertex=(Vertex*)hvertex->delivers();
 	return vertex->dof;
 }
@@ -383,5 +387,5 @@
 	Vertex*  vertex=NULL;
 
-	vertex=(Vertex*)hvertex.delivers();
+	vertex=(Vertex*)hvertex->delivers();
 	vertex->dof=in_dof;
 
@@ -706,5 +710,5 @@
 	Vertex* vertex=NULL;
 
-	vertex=(Vertex*)hvertex.delivers();
+	vertex=(Vertex*)hvertex->delivers();
 	return vertex->sigma;
 }
@@ -713,5 +717,5 @@
 Node* Node::GetUpperNode(){
 	Node* upper_node=NULL;
-	upper_node=(Node*)hupper_node.delivers();
+	upper_node=(Node*)hupper_node->delivers();
 	return upper_node;
 }
@@ -721,5 +725,5 @@
 	Vertex* vertex=NULL;
 
-	vertex=(Vertex*)hvertex.delivers();
+	vertex=(Vertex*)hvertex->delivers();
 	return vertex->x;
 }
@@ -729,5 +733,5 @@
 	Vertex* vertex=NULL;
 
-	vertex=(Vertex*)hvertex.delivers();
+	vertex=(Vertex*)hvertex->delivers();
 	return vertex->y;
 }
@@ -737,5 +741,5 @@
 	Vertex* vertex=NULL;
 
-	vertex=(Vertex*)hvertex.delivers();
+	vertex=(Vertex*)hvertex->delivers();
 	return vertex->z;
 }
Index: /issm/trunk/src/c/objects/Node.h
===================================================================
--- /issm/trunk/src/c/objects/Node.h	(revision 4395)
+++ /issm/trunk/src/c/objects/Node.h	(revision 4396)
@@ -27,6 +27,6 @@
 				
 		DofIndexing    indexing;
-		Hook           hvertex;
-		Hook           hupper_node;
+		Hook*          hvertex;
+		Hook*          hupper_node;
 		Inputs*        inputs; //properties of this node
 		int            analysis_type;
