Index: /issm/trunk/etc/environment.sh
===================================================================
--- /issm/trunk/etc/environment.sh	(revision 3382)
+++ /issm/trunk/etc/environment.sh	(revision 3383)
@@ -126,5 +126,5 @@
 #AUTOMAKE
 export AUTOMAKE_DIR
-PATH="$PATH:$AUTOMAKE_DIR/bin"
+PATH="$AUTOMAKE_DIR/bin:$PATH"
 
 #BORLAND
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.cpp	(revision 3382)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.cpp	(revision 3383)
@@ -68,7 +68,9 @@
 int ObjectEnum(void){                       return          400; }
 /*Elements: */
+int HookEnum(void){                         return          409; }
 int ElementEnum(void){                      return          410; }
 int TriaEnum(void){                         return          411; }
-int PentaEnum(void){                        return          412; }
+int ElementPropertiesEnum(void){               return          412; }
+int PentaEnum(void){                        return          413; }
 int SingEnum(void){                         return          414; }
 int BeamEnum(void){                         return          415; }
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 3382)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 3383)
@@ -69,6 +69,8 @@
 int ObjectEnum(void);
 /*Elements: */
+int HookEnum(void);
 int ElementEnum(void);
 int TriaEnum(void);
+int ElementPropertiesEnum(void);
 int PentaEnum(void);
 int SingEnum(void);
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 3382)
+++ /issm/trunk/src/c/Makefile.am	(revision 3383)
@@ -31,4 +31,6 @@
 					./objects/Element.h\
 					./objects/Element.cpp\
+					./objects/ElementProperties.h\
+					./objects/ElementProperties.cpp\
 					./objects/Model.h\
 					./objects/Model.cpp\
@@ -52,4 +54,6 @@
 					./objects/Node.h\
 					./objects/Node.cpp\
+					./objects/Hook.h\
+					./objects/Hook.cpp\
 					./objects/Result.h\
 					./objects/Result.cpp\
@@ -419,4 +423,6 @@
 					./objects/Element.h\
 					./objects/Element.cpp\
+					./objects/ElementProperties.h\
+					./objects/ElementProperties.cpp\
 					./objects/Model.h\
 					./objects/Model.cpp\
@@ -440,4 +446,6 @@
 					./objects/Node.h\
 					./objects/Node.cpp\
+					./objects/Hook.h\
+					./objects/Hook.cpp\
 					./objects/Result.h\
 					./objects/Result.cpp\
Index: /issm/trunk/src/c/ModelProcessorx/Balancedthickness/CreateElementsNodesAndMaterialsBalancedthickness.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Balancedthickness/CreateElementsNodesAndMaterialsBalancedthickness.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/Balancedthickness/CreateElementsNodesAndMaterialsBalancedthickness.cpp	(revision 3383)
@@ -8,4 +8,5 @@
 #include "../../objects/objects.h"
 #include "../../shared/shared.h"
+#include "../../include/typedefs.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
 #include "../IoModel.h"
@@ -33,4 +34,6 @@
 	Matice*     matice  = NULL;
 	Matpar*     matpar  = NULL;
+	ElementProperties* tria_properties=NULL;
+	ElementProperties* penta_properties=NULL;
 
 	/*output: */
@@ -47,18 +50,11 @@
 	/*tria constructor input: */
 	int tria_id;
-	int tria_mid;
-	int tria_mparid;
-	int tria_numparid;
-	int tria_g[3];
+	int tria_matice_id;
+	int tria_matpar_id;
+	int tria_numpar_id;
+	int tria_node_ids[3];
 	double tria_h[3];
 	double tria_s[3];
 	double tria_b[3];
-	double tria_k[3];
-	double tria_melting[3];
-	double tria_accumulation[3];
-	double tria_geothermalflux[3];
-	int    tria_friction_type;
-	double tria_p;
-	double tria_q;
 	int    tria_shelf;
 	bool   tria_onwater; 
@@ -72,23 +68,15 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
 	double penta_b[6];
-	double penta_k[6];
-	int penta_friction_type;
-	double penta_p;
-	double penta_q;
 	int penta_shelf;
 	int penta_onbed;
 	int penta_onsurface;
 	int penta_collapse;
-	double penta_melting[6];
-	double penta_accumulation[6];
-	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -190,12 +178,12 @@
 			/*ids: */
 			tria_id=i+1; //matlab indexing.
-			tria_mid=-1; //no need for materials
-			tria_mparid=-1; //no need for materials
-			tria_numparid=1;
+			tria_matice_id=-1; //no need for materials
+			tria_matpar_id=-1; //no need for materials
+			tria_numpar_id=1;
 
 			/*vertices offsets: */
-			tria_g[0]=(int)*(iomodel->elements+elements_width*i+0);
-			tria_g[1]=(int)*(iomodel->elements+elements_width*i+1);
-			tria_g[2]=(int)*(iomodel->elements+elements_width*i+2);
+			tria_node_ids[0]=(int)*(iomodel->elements+elements_width*i+0);
+			tria_node_ids[1]=(int)*(iomodel->elements+elements_width*i+1);
+			tria_node_ids[2]=(int)*(iomodel->elements+elements_width*i+2);
 
 			/*thickness,surface and bed:*/
@@ -216,6 +204,12 @@
 			tria_onwater=(bool)*(iomodel->elementonwater+i);
 
+			/*Create properties: */
+			tria_properties=new ElementProperties(3,tria_h, tria_s, tria_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, tria_shelf, UNDEF, tria_onwater, UNDEF, UNDEF, UNDEF);
+
 			/*Create tria element using its constructor:*/
-			tria=new Tria(tria_id, tria_mid, tria_mparid, tria_numparid,tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_onwater);
+			tria=new Tria(tria_id, tria_node_ids, tria_matice_id, tria_matpar_id, tria_numpar_id, tria_properties);
+
+			/*Delete properties: */
+			delete tria_properties;
 
 			/*Add tria element to elements dataset: */
@@ -269,11 +263,11 @@
 			/*name and id: */
 			penta_id=i+1; //matlab indexing.
-			penta_mid=-1; 
-			penta_mparid=-1; //no need for materials
-			penta_numparid=1;
+			penta_matice_id=-1; 
+			penta_matpar_id=-1; //no need for materials
+			penta_numpar_id=1;
 
 			/*vertices,thickness,surface,bed and drag: */
 			for(j=0;j<6;j++){
-				penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+				penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 				penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 				penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -289,9 +283,12 @@
 	
 
+			/*Create properties: */
+			penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);
+
 			/*Create Penta using its constructor:*/
-			penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-					penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-					penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-					penta_thermal_steadystate,penta_onwater); 
+			penta=new Penta(penta_id, penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+			/*Delete properties: */
+			delete penta_properties;
 
 			/*Add penta element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/Balancedvelocities/CreateElementsNodesAndMaterialsBalancedvelocities.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Balancedvelocities/CreateElementsNodesAndMaterialsBalancedvelocities.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/Balancedvelocities/CreateElementsNodesAndMaterialsBalancedvelocities.cpp	(revision 3383)
@@ -9,4 +9,5 @@
 #include "../../shared/shared.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
+#include "../../include/typedefs.h"
 #include "../IoModel.h"
 
@@ -26,4 +27,6 @@
 	DataSet*    nodes = NULL;
 	DataSet*    materials = NULL;
+	ElementProperties* tria_properties=NULL;
+	ElementProperties* penta_properties=NULL;
 	
 	/*Objects: */
@@ -47,18 +50,11 @@
 	/*tria constructor input: */
 	int tria_id;
-	int tria_mid;
-	int tria_mparid;
-	int tria_numparid;
-	int tria_g[3];
+	int tria_matice_id;
+	int tria_matpar_id;
+	int tria_numpar_id;
+	int tria_node_ids[3];
 	double tria_h[3];
 	double tria_s[3];
 	double tria_b[3];
-	double tria_k[3];
-	double tria_melting[3];
-	double tria_accumulation[3];
-	double tria_geothermalflux[3];
-	int    tria_friction_type;
-	double tria_p;
-	double tria_q;
 	int    tria_shelf;
 	bool   tria_onwater; 
@@ -72,23 +68,15 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
 	double penta_b[6];
-	double penta_k[6];
-	int penta_friction_type;
-	double penta_p;
-	double penta_q;
 	int penta_shelf;
 	int penta_onbed;
 	int penta_onsurface;
 	int penta_collapse;
-	double penta_melting[6];
-	double penta_accumulation[6];
-	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -190,12 +178,12 @@
 			/*ids: */
 			tria_id=i+1; //matlab indexing.
-			tria_mid=-1; //no need for materials
-			tria_mparid=-1; //no need for materials
-			tria_numparid=1;
+			tria_matice_id=-1; //no need for materials
+			tria_matpar_id=-1; //no need for materials
+			tria_numpar_id=1;
 
 			/*vertices offsets: */
-			tria_g[0]=(int)*(iomodel->elements+elements_width*i+0);
-			tria_g[1]=(int)*(iomodel->elements+elements_width*i+1);
-			tria_g[2]=(int)*(iomodel->elements+elements_width*i+2);
+			tria_node_ids[0]=(int)*(iomodel->elements+elements_width*i+0);
+			tria_node_ids[1]=(int)*(iomodel->elements+elements_width*i+1);
+			tria_node_ids[2]=(int)*(iomodel->elements+elements_width*i+2);
 
 			/*thickness,surface and bed:*/
@@ -216,6 +204,12 @@
 			tria_onwater=(bool)*(iomodel->elementonwater+i);
 
+			/*Create properties: */
+			tria_properties=new ElementProperties(3,tria_h, tria_s, tria_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, tria_shelf, UNDEF, tria_onwater, UNDEF, UNDEF, UNDEF);
+
 			/*Create tria element using its constructor:*/
-			tria=new Tria(tria_id, tria_mid, tria_mparid, tria_numparid,tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_onwater);
+			tria=new Tria(tria_id, tria_node_ids, tria_matice_id, tria_matpar_id, tria_numpar_id, tria_properties);
+
+			/*Delete properties: */
+			delete tria_properties;
 
 			/*Add tria element to elements dataset: */
@@ -269,11 +263,11 @@
 			/*name and id: */
 			penta_id=i+1; //matlab indexing.
-			penta_mid=-1; 
-			penta_mparid=-1; //no need for materials
-			penta_numparid=1;
+			penta_matice_id=-1; 
+			penta_matpar_id=-1; //no need for materials
+			penta_numpar_id=1;
 
 			/*vertices,thickness,surface,bed and drag: */
 			for(j=0;j<6;j++){
-				penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+				penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 				penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 				penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -288,10 +282,12 @@
 			penta_onwater=(bool)*(iomodel->elementonwater+i);
 	
+			/*Create properties: */
+			penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);
 
 			/*Create Penta using its constructor:*/
-			penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-					penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-					penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-					penta_thermal_steadystate,penta_onwater); 
+			penta=new Penta(penta_id, penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+			/*Delete properties: */
+			delete penta_properties;
 
 			/*Add penta element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateElementsNodesAndMaterialsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateElementsNodesAndMaterialsDiagnosticHoriz.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateElementsNodesAndMaterialsDiagnosticHoriz.cpp	(revision 3383)
@@ -9,4 +9,5 @@
 #include "../../shared/shared.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
+#include "../../include/typedefs.h"
 #include "../IoModel.h"
 
@@ -33,4 +34,6 @@
 	Matice*     matice  = NULL;
 	Matpar*     matpar  = NULL;
+	ElementProperties* tria_properties=NULL;
+	ElementProperties* penta_properties=NULL;
 
 	/*output: */
@@ -47,8 +50,8 @@
 	/*tria constructor input: */
 	int tria_id;
-	int tria_mid;
-	int tria_mparid;
-	int tria_numparid;
-	int tria_g[3];
+	int tria_matice_id;
+	int tria_matpar_id;
+	int tria_numpar_id;
+	int tria_node_ids[3];
 	double tria_h[3];
 	double tria_s[3];
@@ -57,5 +60,4 @@
 	double tria_melting[3];
 	double tria_accumulation[3];
-	double tria_geothermalflux[3];
 	int    tria_friction_type;
 	double tria_p;
@@ -71,8 +73,8 @@
 	/*penta constructor input: */
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
@@ -88,6 +90,4 @@
 	double penta_melting[6];
 	double penta_accumulation[6];
-	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -218,12 +218,12 @@
 				/*ids: */
 				tria_id=i+1; //matlab indexing.
-				tria_mid=i+1; //refers to the corresponding material property card
-				tria_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
-				tria_numparid=1;
-
-				/*vertices offsets: */
-				tria_g[0]=(int)*(iomodel->elements+elements_width*i+0);
-				tria_g[1]=(int)*(iomodel->elements+elements_width*i+1);
-				tria_g[2]=(int)*(iomodel->elements+elements_width*i+2);
+				tria_matice_id=i+1; //refers to the corresponding material property card
+				tria_matpar_id=iomodel->numberofelements+1;//refers to the corresponding parmat property card
+				tria_numpar_id=1;
+
+				/*vertices ids: */
+				tria_node_ids[0]=(int)*(iomodel->elements+elements_width*i+0);
+				tria_node_ids[1]=(int)*(iomodel->elements+elements_width*i+1);
+				tria_node_ids[2]=(int)*(iomodel->elements+elements_width*i+2);
 
 				/*thickness,surface and bed:*/
@@ -263,6 +263,13 @@
 				tria_onwater=(bool)*(iomodel->elementonwater+i);
 
+				/*Create properties: */
+				tria_properties=new ElementProperties(3,tria_h, tria_s, tria_b, tria_k, tria_melting, tria_accumulation, NULL,
+						tria_friction_type, tria_p, tria_q, tria_shelf, UNDEF,tria_onwater, UNDEF,UNDEF,UNDEF);
+
 				/*Create tria element using its constructor:*/
-				tria=new Tria(tria_id, tria_mid, tria_mparid, tria_numparid,tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_onwater);
+				tria=new Tria(tria_id, tria_node_ids, tria_matice_id, tria_matpar_id, tria_numpar_id, tria_properties);
+
+				/*delete properties: */
+				delete tria_properties;
 
 				/*Add tria element to elements dataset: */
@@ -351,11 +358,11 @@
 				/*name and id: */
 				penta_id=i+1; //matlab indexing.
-				penta_mid=i+1; //refers to the corresponding material property card
-				penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
-				penta_numparid=1;
+				penta_matice_id=i+1; //refers to the corresponding material property card
+				penta_matpar_id=iomodel->numberofelements+1;//refers to the corresponding parmat property card
+				penta_numpar_id=1;
 
 				/*vertices,thickness,surface,bed and drag: */
 				for(j=0;j<6;j++){
-					penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+					penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 					penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 					penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -385,10 +392,12 @@
 				}
 
+				/*Create element properties: */
+				penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, penta_k, penta_melting, penta_accumulation, NULL, penta_friction_type, penta_p, penta_q, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);
 
 				/*Create Penta using its constructor:*/
-				penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-						penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-						penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-						penta_thermal_steadystate,penta_onwater); 
+				penta= new Penta(penta_id,penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+				/*delete properties: */
+				delete penta_properties;
 
 				/*Add penta element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp	(revision 3383)
@@ -9,4 +9,5 @@
 #include "../../shared/shared.h"
 #include "../../include/macros.h"
+#include "../../include/typedefs.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
 #include "../IoModel.h"
@@ -32,4 +33,5 @@
 	Matice*     matice  = NULL;
 	Matpar*     matpar  = NULL;
+	ElementProperties* penta_properties=NULL;
 
 	/*output: */
@@ -52,8 +54,8 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
@@ -69,6 +71,4 @@
 	double penta_melting[6];
 	double penta_accumulation[6];
-	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -185,11 +185,11 @@
 			/*name and id: */
 			penta_id=i+1; //matlab indexing.
-			penta_mid=i+1; //refers to the corresponding material property card
-			penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
-			penta_numparid=1;
+			penta_matice_id=i+1; //refers to the corresponding material property card
+			penta_matpar_id=iomodel->numberofelements+1;//refers to the corresponding parmat property card
+			penta_numpar_id=1;
 
 			/*vertices,thickness,surface,bed and drag: */
 			for(j=0;j<6;j++){
-				penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+				penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 				penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 				penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -211,12 +211,16 @@
 			penta_onsurface=(int)*(iomodel->elementonsurface+i);
 			penta_onwater=(bool)*(iomodel->elementonwater+i);
+			penta_collapse=0;
 	
 			if (*(iomodel->elements_type+2*i+1)==StokesFormulationEnum()){
-			
+		
+				/*Create properties: */
+				penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, penta_k, penta_melting, penta_accumulation, NULL, penta_friction_type, penta_p, penta_q, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);	
+				
 				/*Create Penta using its constructor:*/
-				penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-						penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-						penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-						penta_thermal_steadystate,penta_onwater); 
+				penta=new Penta(penta_id,penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+				/*Delete properties: */
+				delete penta_properties;
 
 				/*Add penta element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp	(revision 3383)
@@ -10,4 +10,5 @@
 #include "../../shared/shared.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
+#include "../../include/typedefs.h"
 #include "../IoModel.h"
 
@@ -33,4 +34,5 @@
 	Matice*     matice  = NULL;
 	Matpar*     matpar  = NULL;
+	ElementProperties* penta_properties=NULL;
 
 	/*output: */
@@ -53,15 +55,11 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
 	double penta_b[6];
-	double penta_k[6];
-	int penta_friction_type;
-	double penta_p;
-	double penta_q;
 	int penta_shelf;
 	int penta_onbed;
@@ -70,7 +68,5 @@
 	double penta_melting[6];
 	double penta_accumulation[6];
-	double penta_geothermalflux[6];
 	int penta_artdiff;
-	int penta_thermal_steadystate;
 	double penta_viscosity_overshoot;
 	double penta_stokesreconditioning;
@@ -177,11 +173,11 @@
 		/*name and id: */
 		penta_id=i+1; //matlab indexing.
-		penta_mid=i+1; //refers to the corresponding material property card
-		penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
-		penta_numparid=1;
+		penta_matice_id=i+1; //refers to the corresponding material property card
+		penta_matpar_id=iomodel->numberofelements+1;//refers to the corresponding parmat property card
+		penta_numpar_id=1;
 
 		/*vertices,thickness,surface,bed and drag: */
 		for(j=0;j<6;j++){
-			penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+			penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 			penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 			penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -198,9 +194,12 @@
 		penta_onwater=(bool)*(iomodel->elementonwater+i);
 
+		/*Create properties: */
+		penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, NULL, penta_melting, penta_accumulation, NULL, UNDEF,UNDEF,UNDEF, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);
+
 		/*Create Penta using its constructor:*/
-		penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-				penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-				penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-				penta_thermal_steadystate,penta_onwater); 
+		penta=new Penta(penta_id,penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+		/*delete properties: */
+		delete penta_properties;
 
 		/*Add penta element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp	(revision 3383)
@@ -6,4 +6,5 @@
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../include/typedefs.h"
 #include "../../objects/objects.h"
 #include "../../shared/shared.h"
@@ -32,4 +33,5 @@
 	Matice*     matice  = NULL;
 	Matpar*     matpar  = NULL;
+	ElementProperties* penta_properties=NULL;
 	
 	/*output: */
@@ -52,8 +54,8 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
@@ -69,6 +71,4 @@
 	double penta_melting[6];
 	double penta_accumulation[6];
-	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -165,11 +165,11 @@
 		/*name and id: */
 		penta_id=i+1; //matlab indexing.
-		penta_mid=i+1; //refers to the corresponding material property card
-		penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
-		penta_numparid=1;
+		penta_matice_id=i+1; //refers to the corresponding material property card
+		penta_matpar_id=iomodel->numberofelements+1;//refers to the corresponding parmat property card
+		penta_numpar_id=1;
 
 		/*vertices,thickness,surface,bed and drag: */
 		for(j=0;j<6;j++){
-			penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+			penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 			penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 			penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -193,9 +193,12 @@
 		penta_collapse=1;
 
+		/*Create properties: */
+		penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, penta_k, penta_melting, penta_accumulation, NULL, penta_friction_type, penta_p, penta_q, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);
+
 		/*Create Penta using its constructor:*/
-		penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-				penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-				penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-				penta_thermal_steadystate,penta_onwater); 
+		penta=new Penta(penta_id, penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+		/*Delete properties: */
+		delete penta_properties;
 
 		/*Add penta element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp	(revision 3383)
@@ -10,4 +10,5 @@
 #include "../../shared/shared.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
+#include "../../include/typedefs.h"
 #include "../IoModel.h"
 
@@ -34,4 +35,6 @@
 	Matice*     matice  = NULL;
 	Matpar*     matpar  = NULL;
+	ElementProperties* tria_properties=NULL;
+	ElementProperties* penta_properties=NULL;
 
 	/*output: */
@@ -48,18 +51,11 @@
 	/*tria constructor input: */
 	int tria_id;
-	int tria_mid;
-	int tria_mparid;
-	int tria_numparid;
-	int tria_g[3];
+	int tria_matice_id;
+	int tria_matpar_id;
+	int tria_numpar_id;
+	int tria_node_ids[3];
 	double tria_h[3];
 	double tria_s[3];
 	double tria_b[3];
-	double tria_k[3];
-	double tria_melting[3];
-	double tria_accumulation[3];
-	double tria_geothermalflux[3];
-	int    tria_friction_type;
-	double tria_p;
-	double tria_q;
 	int    tria_shelf;
 	bool   tria_onwater; 
@@ -73,23 +69,15 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
 	double penta_b[6];
-	double penta_k[6];
-	int penta_friction_type;
-	double penta_p;
-	double penta_q;
 	int penta_shelf;
 	int penta_onbed;
 	int penta_onsurface;
 	int penta_collapse;
-	double penta_melting[6];
-	double penta_accumulation[6];
-	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -191,12 +179,12 @@
 			/*ids: */
 			tria_id=i+1; //matlab indexing.
-			tria_mid=-1; //no need for materials
-			tria_mparid=-1; //no need for materials
-			tria_numparid=1;
+			tria_matice_id=-1; //no need for materials
+			tria_matpar_id=-1; //no need for materials
+			tria_numpar_id=1;
 
 			/*vertices offsets: */
-			tria_g[0]=(int)*(iomodel->elements+elements_width*i+0);
-			tria_g[1]=(int)*(iomodel->elements+elements_width*i+1);
-			tria_g[2]=(int)*(iomodel->elements+elements_width*i+2);
+			tria_node_ids[0]=(int)*(iomodel->elements+elements_width*i+0);
+			tria_node_ids[1]=(int)*(iomodel->elements+elements_width*i+1);
+			tria_node_ids[2]=(int)*(iomodel->elements+elements_width*i+2);
 
 			/*thickness,surface and bed:*/
@@ -217,6 +205,12 @@
 			tria_onwater=(bool)*(iomodel->elementonwater+i);
 
+			/*Create properties: */
+			tria_properties=new ElementProperties(3,tria_h, tria_s, tria_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, tria_shelf, UNDEF, tria_onwater, UNDEF, UNDEF, UNDEF);
+
 			/*Create tria element using its constructor:*/
-			tria=new Tria(tria_id, tria_mid, tria_mparid, tria_numparid,tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_onwater);
+			tria=new Tria(tria_id, tria_node_ids, tria_matice_id, tria_matpar_id, tria_numpar_id, tria_properties);
+
+			/*Delete properties: */
+			delete tria_properties;
 
 			/*Add tria element to elements dataset: */
@@ -270,11 +264,11 @@
 			/*name and id: */
 			penta_id=i+1; //matlab indexing.
-			penta_mid=-1; 
-			penta_mparid=-1; //no need for materials
-			penta_numparid=1;
+			penta_matice_id=-1; 
+			penta_matpar_id=-1; //no need for materials
+			penta_numpar_id=1;
 
 			/*vertices,thickness,surface,bed and drag: */
 			for(j=0;j<6;j++){
-				penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+				penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 				penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 				penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -289,10 +283,12 @@
 			penta_onwater=(bool)*(iomodel->elementonwater+i);
 	
+			/*Create properties: */
+			penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);
 
 			/*Create Penta using its constructor:*/
-			penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-					penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-					penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-					penta_thermal_steadystate,penta_onwater); 
+			penta=new Penta(penta_id, penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+			/*Delete properties: */
+			delete penta_properties;
 
 			/*Add penta element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/Prognostic2/CreateElementsNodesAndMaterialsPrognostic2.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Prognostic2/CreateElementsNodesAndMaterialsPrognostic2.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/Prognostic2/CreateElementsNodesAndMaterialsPrognostic2.cpp	(revision 3383)
@@ -30,4 +30,5 @@
 	Matice* matice  = NULL;
 	Matpar* matpar  = NULL;
+	ElementProperties* tria_properties=NULL; 
 
 	/*output: */
@@ -43,18 +44,11 @@
 	/*tria constructor input: */
 	int tria_id;
-	int tria_mid;
-	int tria_mparid;
-	int tria_numparid;
-	int tria_g[3];
+	int tria_matice_id;
+	int tria_matpar_id;
+	int tria_numpar_id;
+	int tria_node_ids[3];
 	double tria_h[3];
 	double tria_s[3];
 	double tria_b[3];
-	double tria_k[3];
-	double tria_melting[3];
-	double tria_accumulation[3];
-	double tria_geothermalflux[3];
-	int    tria_friction_type;
-	double tria_p;
-	double tria_q;
 	int    tria_shelf;
 	bool   tria_onwater; 
@@ -76,5 +70,4 @@
 	double penta_b[6];
 	double penta_k[6];
-	int penta_friction_type;
 	double penta_p;
 	double penta_q;
@@ -85,5 +78,4 @@
 	double penta_melting[6];
 	double penta_accumulation[6];
-	double penta_geothermalflux[6];
 	int penta_thermal_steadystate;
 	bool   penta_onwater;
@@ -188,12 +180,12 @@
 			/*ids: */
 			tria_id=i+1; //matlab indexing.
-			tria_mid=-1; //no need for materials
-			tria_mparid=-1; //no need for materials
-			tria_numparid=1;
+			tria_matice_id=-1; //no need for materials
+			tria_matpar_id=-1; //no need for materials
+			tria_numpar_id=1;
 
 			/*vertices offsets: */
-			tria_g[0]=3*i+1;
-			tria_g[1]=3*i+2;
-			tria_g[2]=3*i+3;
+			tria_node_ids[0]=3*i+1;
+			tria_node_ids[1]=3*i+2;
+			tria_node_ids[2]=3*i+3;
 
 			/*thickness,surface and bed:*/
@@ -214,6 +206,12 @@
 			tria_onwater=(bool)*(iomodel->elementonwater+i);
 
+			/*Create properties: */
+			tria_properties=new ElementProperties(3,tria_h, tria_s, tria_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, tria_shelf, UNDEF, tria_onwater, UNDEF, UNDEF, UNDEF);
+
 			/*Create tria element using its constructor:*/
-			tria=new Tria(tria_id, tria_mid, tria_mparid, tria_numparid,tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_onwater);
+			tria=new Tria(tria_id, tria_node_ids, tria_matice_id, tria_matpar_id, tria_numpar_id, tria_properties);
+
+			/*Delete properties: */
+			delete tria_properties;
 
 			/*Add tria element to elements dataset: */
Index: /issm/trunk/src/c/ModelProcessorx/SlopeCompute/CreateElementsNodesAndMaterialsSlopeCompute.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/SlopeCompute/CreateElementsNodesAndMaterialsSlopeCompute.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/SlopeCompute/CreateElementsNodesAndMaterialsSlopeCompute.cpp	(revision 3383)
@@ -9,7 +9,7 @@
 #include "../../objects/objects.h"
 #include "../../shared/shared.h"
+#include "../../include/typedefs.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
 #include "../IoModel.h"
-
 
 void	CreateElementsNodesAndMaterialsSlopeCompute(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, IoModel* iomodel,ConstDataHandle iomodel_handle){
@@ -32,4 +32,6 @@
 	Tria*       tria = NULL;
 	Penta*      penta = NULL;
+	ElementProperties* tria_properties=NULL;
+	ElementProperties* penta_properties=NULL;
 
 	/*output: */
@@ -44,19 +46,10 @@
 	/*tria constructor input: */
 	int tria_id;
-	int tria_mid;
-	int tria_mparid;
-	int tria_numparid;
-	int tria_g[3];
-	double tria_h[3];
+	int tria_matice_id;
+	int tria_matpar_id;
+	int tria_numpar_id;
+	int tria_node_ids[3];
 	double tria_s[3];
 	double tria_b[3];
-	double tria_k[3];
-	double tria_melting[3];
-	double tria_accumulation[3];
-	double tria_geothermalflux[3];
-	int    tria_friction_type;
-	double tria_p;
-	double tria_q;
-	int    tria_shelf;
 	bool   tria_onwater; 
 
@@ -64,23 +57,11 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
-	double penta_h[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_s[6];
 	double penta_b[6];
-	double penta_k[6];
-	int penta_friction_type;
-	double penta_p;
-	double penta_q;
-	int penta_shelf;
 	int penta_onbed;
-	int penta_onsurface;
-	int penta_collapse;
-	double penta_melting[6];
-	double penta_accumulation[6];
-	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -171,12 +152,12 @@
 			/*ids: */
 			tria_id=i+1; //matlab indexing.
-			tria_mid=-1; //no materials
-			tria_mparid=-1; //no materials
-			tria_numparid=1; //no materials
+			tria_matice_id=-1; //no materials
+			tria_matpar_id=-1; //no materials
+			tria_numpar_id=1; //no materials
 
 			/*vertices offsets: */
-			tria_g[0]=(int)*(iomodel->elements+elements_width*i+0);
-			tria_g[1]=(int)*(iomodel->elements+elements_width*i+1);
-			tria_g[2]=(int)*(iomodel->elements+elements_width*i+2);
+			tria_node_ids[0]=(int)*(iomodel->elements+elements_width*i+0);
+			tria_node_ids[1]=(int)*(iomodel->elements+elements_width*i+1);
+			tria_node_ids[2]=(int)*(iomodel->elements+elements_width*i+2);
 
 			/*surface and bed:*/
@@ -192,6 +173,12 @@
 			tria_onwater=(bool)*(iomodel->elementonwater+i);
 
+			/*Create properties: */
+			tria_properties=new ElementProperties(3,NULL, tria_s, tria_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF, UNDEF, UNDEF, tria_onwater, UNDEF, UNDEF, UNDEF);
+
 			/*Create tria element using its constructor:*/
-			tria=new Tria(tria_id, tria_mid, tria_mparid, tria_numparid,tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_onwater);
+			tria=new Tria(tria_id, tria_node_ids, tria_matice_id, tria_matpar_id, tria_numpar_id, tria_properties);
+
+			/*Delete properties: */
+			delete tria_properties;
 
 			/*Add tria element to elements dataset: */
@@ -240,12 +227,12 @@
 			/*name and id: */
 			penta_id=i+1; //matlab indexing.
-			penta_mid=-1; //no materials
-			penta_mparid=-1; //no materials
-			penta_numparid=1; //no materials
+			penta_matice_id=-1; //no materials
+			penta_matpar_id=-1; //no materials
+			penta_numpar_id=1; //no materials
 			
 
 			/*vertices,thickness,surface,bed and drag: */
 			for(j=0;j<6;j++){
-				penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+				penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 				penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 				penta_b[j]=*(iomodel->bed+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -256,14 +243,16 @@
 			penta_onwater=(bool)*(iomodel->elementonwater+i);
 
+			/*Create properties: */
+			penta_properties=new ElementProperties(6,NULL, penta_s, penta_b, NULL, NULL, NULL, NULL, UNDEF, UNDEF, UNDEF,UNDEF,penta_onbed, penta_onwater, UNDEF, UNDEF, UNDEF);
+				
 			/*Create Penta using its constructor:*/
-			penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-					penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-					penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-					penta_thermal_steadystate,penta_onwater); 
+			penta=new Penta(penta_id, penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+			/*Delete properties: */
+			delete penta_properties;
 
 			/*Add penta element to elements dataset: */
 			elements->AddObject(penta);
 	
-
 			#ifdef _PARALLEL_
 			/*Now that we are here, we can also start building the list of grids belonging to this node partition: we use 
Index: /issm/trunk/src/c/ModelProcessorx/Thermal/CreateElementsNodesAndMaterialsThermal.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Thermal/CreateElementsNodesAndMaterialsThermal.cpp	(revision 3382)
+++ /issm/trunk/src/c/ModelProcessorx/Thermal/CreateElementsNodesAndMaterialsThermal.cpp	(revision 3383)
@@ -7,4 +7,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 #include "../../objects/objects.h"
+#include "../../include/typedefs.h"
 #include "../../shared/shared.h"
 #include "../../MeshPartitionx/MeshPartitionx.h"
@@ -31,4 +32,5 @@
 	Matice*     matice  = NULL;
 	Matpar*     matpar  = NULL;
+	ElementProperties* penta_properties=NULL;
 
 	/*output: */
@@ -51,8 +53,8 @@
 
 	int penta_id;
-	int penta_mid;
-	int penta_mparid;
-	int penta_numparid;
-	int penta_g[6];
+	int penta_matice_id;
+	int penta_matpar_id;
+	int penta_numpar_id;
+	int penta_node_ids[6];
 	double penta_h[6];
 	double penta_s[6];
@@ -66,8 +68,5 @@
 	int penta_onsurface;
 	int penta_collapse;
-	double penta_melting[6];
-	double penta_accumulation[6];
 	double penta_geothermalflux[6];
-	int penta_thermal_steadystate;
 	bool   penta_onwater;
 
@@ -162,11 +161,11 @@
 		/*name and id: */
 		penta_id=i+1; //matlab indexing.
-		penta_mid=i+1; //refers to the corresponding material property card
-		penta_mparid=iomodel->numberofelements+1;//refers to the corresponding parmat property card
-		penta_numparid=1;
+		penta_matice_id=i+1; //refers to the corresponding material property card
+		penta_matpar_id=iomodel->numberofelements+1;//refers to the corresponding parmat property card
+		penta_numpar_id=1;
 
 		/*vertices,thickness,surface,bed and drag: */
 		for(j=0;j<6;j++){
-			penta_g[j]=(int)*(iomodel->elements+elements_width*i+j);
+			penta_node_ids[j]=(int)*(iomodel->elements+elements_width*i+j);
 			penta_h[j]=*(iomodel->thickness+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
 			penta_s[j]=*(iomodel->surface+    ((int)*(iomodel->elements+elements_width*i+j)-1)); 
@@ -196,14 +195,15 @@
 		}
 
+		/*Create properties: */
+		penta_properties=new ElementProperties(6,penta_h, penta_s, penta_b, penta_k, NULL, NULL, penta_geothermalflux, penta_friction_type, penta_p, penta_q, penta_shelf, penta_onbed, penta_onwater, penta_onsurface, penta_collapse, UNDEF);
 
 		/*Create Penta using its constructor:*/
-		penta= new Penta( penta_id,penta_mid,penta_mparid,penta_numparid,penta_g,penta_h,penta_s,penta_b,penta_k,penta_friction_type,
-				penta_p,penta_q,penta_shelf,penta_onbed,penta_onsurface,
-				penta_collapse,penta_melting,penta_accumulation,penta_geothermalflux,
-				penta_thermal_steadystate,penta_onwater); 
+		penta=new Penta(penta_id, penta_node_ids, penta_matice_id, penta_matpar_id, penta_numpar_id, penta_properties);
+
+		/*Delete properties: */
+		delete penta_properties;
 
 		/*Add penta element to elements dataset: */
 		elements->AddObject(penta);
-
 
 		/*Deal with material:*/
Index: /issm/trunk/src/c/objects/ElementProperties.cpp
===================================================================
--- /issm/trunk/src/c/objects/ElementProperties.cpp	(revision 3383)
+++ /issm/trunk/src/c/objects/ElementProperties.cpp	(revision 3383)
@@ -0,0 +1,419 @@
+/*!\file ElementProperties.c
+ * \brief: implementation of the ElementProperties object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include "./ElementProperties.h"
+#include <string.h>
+#include "../EnumDefinitions/EnumDefinitions.h"
+#include "../shared/shared.h"
+#include "../DataSet/DataSet.h"
+#include "../include/typedefs.h"
+#include "../include/macros.h"
+
+/*Object constructors and destructor*/
+/*FUNCTION ElementProperties default constructor {{{1*/
+ElementProperties::ElementProperties(){
+	
+	int i;
+
+
+	/*initialize to 0 every value: */
+	this->numnodes=0;
+	this->h=NULL;
+	this->s=NULL;
+	this->b=NULL;
+	this->k=NULL;
+	this->melting=NULL;
+	this->accumulation=NULL;
+	this->geothermalflux=NULL;
+	
+	this->friction_type=0;
+	this->p=0;
+	this->q=0;
+	this->shelf=0;
+	this->onbed=0;
+	this->onwater=0;
+	this->onsurface=0;
+	this->collapse=0;
+	this->thermal_steadystate=0;
+	return;
+}
+/*}}}*/
+/*FUNCTION ElementProperties constructor {{{1*/
+
+ElementProperties::ElementProperties(int elementproperties_numnodes, double* elementproperties_h,double* elementproperties_s,double* elementproperties_b,
+		double* elementproperties_k,double* elementproperties_melting,double* elementproperties_accumulation,
+		double* elementproperties_geothermalflux, int elementproperties_friction_type,double elementproperties_p,
+		double elementproperties_q, int elementproperties_shelf, int elementproperties_onbed, bool elementproperties_onwater, 
+		int elementproperties_onsurface, int elementproperties_collapse, int elementproperties_thermal_steadystate){
+
+	int i;
+
+	this->numnodes=elementproperties_numnodes;
+
+	if(elementproperties_h)this->h=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(elementproperties_s)this->s=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(elementproperties_b)this->b=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(elementproperties_k)this->k=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(elementproperties_melting)this->melting=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(elementproperties_accumulation)this->accumulation=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(elementproperties_geothermalflux)this->geothermalflux=(double*)xmalloc(this->numnodes*sizeof(double));
+
+	for(i=0;i<this->numnodes;i++){
+		if(elementproperties_h)this->h[i]=elementproperties_h[i];
+		if(elementproperties_s)this->s[i]=elementproperties_s[i];
+		if(elementproperties_b)this->b[i]=elementproperties_b[i];
+		if(elementproperties_k)this->k[i]=elementproperties_k[i];
+		if(elementproperties_melting)this->melting[i]=elementproperties_melting[i];
+		if(elementproperties_accumulation)this->accumulation[i]=elementproperties_accumulation[i];
+		if(elementproperties_geothermalflux)this->geothermalflux[i]=elementproperties_geothermalflux[i];
+	}
+	
+	this->friction_type=elementproperties_friction_type;
+	this->p=elementproperties_p;
+	this->q=elementproperties_q;
+	this->shelf=elementproperties_shelf;
+	this->onbed=elementproperties_onbed;
+	this->onwater=elementproperties_onwater;
+	this->onsurface=elementproperties_onsurface;
+	this->collapse=elementproperties_collapse;
+	this->thermal_steadystate=elementproperties_thermal_steadystate;
+	
+	return;
+}
+/*}}}*/
+/*FUNCTION ElementProperties copy constructor{{{1*/
+ElementProperties::ElementProperties(ElementProperties* prop){ //copy constructor
+	
+	int i;
+
+	this->numnodes=prop->numnodes;
+
+	if(prop->h)this->h=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(prop->s)this->s=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(prop->b)this->b=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(prop->k)this->k=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(prop->melting)this->melting=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(prop->accumulation)this->accumulation=(double*)xmalloc(this->numnodes*sizeof(double));
+	if(prop->geothermalflux)this->geothermalflux=(double*)xmalloc(this->numnodes*sizeof(double));
+
+	for(i=0;i<this->numnodes;i++){
+		if(prop->h)this->h[i]=prop->h[i];
+		if(prop->s)this->s[i]=prop->s[i];
+		if(prop->b)this->b[i]=prop->b[i];
+		if(prop->k)this->k[i]=prop->k[i];
+		if(prop->melting)this->melting[i]=prop->melting[i];
+		if(prop->accumulation)this->accumulation[i]=prop->accumulation[i];
+		if(prop->geothermalflux)this->geothermalflux[i]=prop->geothermalflux[i];
+	}
+	
+	this->friction_type=prop->friction_type;
+	this->p=prop->p;
+	this->q=prop->q;
+	this->shelf=prop->shelf;
+	this->onbed=prop->onbed;
+	this->onwater=prop->onwater;
+	this->onsurface=prop->onsurface;
+	this->collapse=prop->collapse;
+	this->thermal_steadystate=prop->thermal_steadystate;
+
+	return;
+}
+/*}}}*/
+/*FUNCTION ElementProperties destructor {{{1*/
+ElementProperties::~ElementProperties(){ //destructor
+
+	if(this->h)xfree((void**)&this->h);
+	if(this->s)xfree((void**)&this->s);
+	if(this->b)xfree((void**)&this->b);
+	if(this->k)xfree((void**)&this->k);
+	if(this->melting)xfree((void**)&this->melting);
+	if(this->accumulation)xfree((void**)&this->accumulation);
+	if(this->geothermalflux)xfree((void**)&this->geothermalflux);
+
+	return;
+}
+/*}}}*/
+/*FUNCTION ElementProperties Marshall{{{1*/
+void  ElementProperties::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_type=0;
+	int   nill=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum type of ElementProperties: */
+	enum_type=ElementPropertiesEnum();
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	
+	memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes);
+
+	if(this->h){
+		memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes); 
+		memcpy(marshalled_dataset,this->h,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	else memcpy(marshalled_dataset,&nill,sizeof(nill));marshalled_dataset+=sizeof(nill); 
+
+	if(this->s){
+		memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes); 
+		memcpy(marshalled_dataset,this->s,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	else memcpy(marshalled_dataset,&nill,sizeof(nill));marshalled_dataset+=sizeof(nill); 
+
+	if(this->b){
+		memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes); 
+		memcpy(marshalled_dataset,this->b,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	else memcpy(marshalled_dataset,&nill,sizeof(nill));marshalled_dataset+=sizeof(nill); 
+
+	if(this->k){
+		memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes); 
+		memcpy(marshalled_dataset,this->k,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	else memcpy(marshalled_dataset,&nill,sizeof(nill));marshalled_dataset+=sizeof(nill); 
+
+	if(this->melting){
+		memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes); 
+		memcpy(marshalled_dataset,this->melting,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	else memcpy(marshalled_dataset,&nill,sizeof(nill));marshalled_dataset+=sizeof(nill); 
+
+	if(this->accumulation){
+		memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes); 
+		memcpy(marshalled_dataset,this->accumulation,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	else memcpy(marshalled_dataset,&nill,sizeof(nill));marshalled_dataset+=sizeof(nill); 
+
+
+	if(this->geothermalflux){
+		memcpy(marshalled_dataset,&this->numnodes,sizeof(this->numnodes));marshalled_dataset+=sizeof(this->numnodes); 
+		memcpy(marshalled_dataset,this->geothermalflux,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	else memcpy(marshalled_dataset,&nill,sizeof(nill));marshalled_dataset+=sizeof(nill); 
+
+	memcpy(marshalled_dataset,&friction_type,sizeof(friction_type));marshalled_dataset+=sizeof(friction_type);
+	memcpy(marshalled_dataset,&p,sizeof(p));marshalled_dataset+=sizeof(p);
+	memcpy(marshalled_dataset,&q,sizeof(q));marshalled_dataset+=sizeof(q);
+	memcpy(marshalled_dataset,&shelf,sizeof(shelf));marshalled_dataset+=sizeof(shelf);
+	memcpy(marshalled_dataset,&onbed,sizeof(onbed));marshalled_dataset+=sizeof(onbed);
+	memcpy(marshalled_dataset,&onwater,sizeof(onwater));marshalled_dataset+=sizeof(onwater);
+	memcpy(marshalled_dataset,&onsurface,sizeof(onsurface));marshalled_dataset+=sizeof(onsurface);
+	memcpy(marshalled_dataset,&collapse,sizeof(collapse));marshalled_dataset+=sizeof(collapse);
+	memcpy(marshalled_dataset,&thermal_steadystate,sizeof(thermal_steadystate));marshalled_dataset+=sizeof(thermal_steadystate);
+
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION ElementProperties MarshallSize{{{1*/
+int ElementProperties::MarshallSize(){
+
+	int size;
+
+	size=sizeof(numnodes);
+
+	if(this->h)size+=sizeof(int)+numnodes*sizeof(double); else size+=sizeof(int);
+	if(this->s)size+=sizeof(int)+numnodes*sizeof(double); else size+=sizeof(int);
+	if(this->b)size+=sizeof(int)+numnodes*sizeof(double); else size+=sizeof(int);
+	if(this->k)size+=sizeof(int)+numnodes*sizeof(double); else size+=sizeof(int);
+	if(this->melting)size+=sizeof(int)+numnodes*sizeof(double); else size+=sizeof(int);
+	if(this->accumulation)size+=sizeof(int)+numnodes*sizeof(double); else size+=sizeof(int);
+	if(this->geothermalflux)size+=sizeof(int)+numnodes*sizeof(double); else size+=sizeof(int);
+
+	size+= sizeof(friction_type)+
+		sizeof(p)+
+		sizeof(q)+
+		sizeof(shelf)+
+		sizeof(onbed)+
+		sizeof(onwater)+
+		sizeof(onsurface)+
+		sizeof(collapse)+
+		sizeof(thermal_steadystate)+
+		sizeof(int); //sizeof(int) for enum type
+
+	return size;
+
+}
+/*}}}*/
+/*FUNCTION ElementProperties Demarshall{{{1*/
+void  ElementProperties::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   nonnill=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+
+	memcpy(&numnodes,marshalled_dataset,sizeof(numnodes));marshalled_dataset+=sizeof(numnodes);
+	
+	memcpy(&nonnill,marshalled_dataset,sizeof(nonnill));marshalled_dataset+=sizeof(nonnill);
+	if(nonnill){
+		this->h=(double*)xmalloc(this->numnodes*sizeof(double));
+		memcpy(this->h,marshalled_dataset,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+
+	memcpy(&nonnill,marshalled_dataset,sizeof(nonnill));marshalled_dataset+=sizeof(nonnill);
+	if(nonnill){
+		this->s=(double*)xmalloc(this->numnodes*sizeof(double));
+		memcpy(this->s,marshalled_dataset,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	
+	memcpy(&nonnill,marshalled_dataset,sizeof(nonnill));marshalled_dataset+=sizeof(nonnill);
+	if(nonnill){
+		this->b=(double*)xmalloc(this->numnodes*sizeof(double));
+		memcpy(this->b,marshalled_dataset,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}	
+
+	memcpy(&nonnill,marshalled_dataset,sizeof(nonnill));marshalled_dataset+=sizeof(nonnill);
+	if(nonnill){
+		this->k=(double*)xmalloc(this->numnodes*sizeof(double));
+		memcpy(this->k,marshalled_dataset,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	
+	memcpy(&nonnill,marshalled_dataset,sizeof(nonnill));marshalled_dataset+=sizeof(nonnill);
+	if(nonnill){
+		this->melting=(double*)xmalloc(this->numnodes*sizeof(double));
+		memcpy(this->melting,marshalled_dataset,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	
+	memcpy(&nonnill,marshalled_dataset,sizeof(nonnill));marshalled_dataset+=sizeof(nonnill);
+	if(nonnill){
+		this->accumulation=(double*)xmalloc(this->numnodes*sizeof(double));
+		memcpy(this->accumulation,marshalled_dataset,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	
+	memcpy(&nonnill,marshalled_dataset,sizeof(nonnill));marshalled_dataset+=sizeof(nonnill);
+	if(nonnill){
+		this->geothermalflux=(double*)xmalloc(this->numnodes*sizeof(double));
+		memcpy(this->geothermalflux,marshalled_dataset,this->numnodes*sizeof(double));marshalled_dataset+=this->numnodes*sizeof(double);
+	}
+	
+	
+	memcpy(&friction_type,marshalled_dataset,sizeof(friction_type));marshalled_dataset+=sizeof(friction_type);
+	memcpy(&p,marshalled_dataset,sizeof(p));marshalled_dataset+=sizeof(p);
+	memcpy(&q,marshalled_dataset,sizeof(q));marshalled_dataset+=sizeof(q);
+	memcpy(&shelf,marshalled_dataset,sizeof(shelf));marshalled_dataset+=sizeof(shelf);
+	memcpy(&onbed,marshalled_dataset,sizeof(onbed));marshalled_dataset+=sizeof(onbed);
+	memcpy(&onwater,marshalled_dataset,sizeof(onwater));marshalled_dataset+=sizeof(onwater);
+	memcpy(&onsurface,marshalled_dataset,sizeof(onsurface));marshalled_dataset+=sizeof(onsurface);
+	memcpy(&collapse,marshalled_dataset,sizeof(collapse));marshalled_dataset+=sizeof(collapse);
+	memcpy(&thermal_steadystate,marshalled_dataset,sizeof(thermal_steadystate));marshalled_dataset+=sizeof(thermal_steadystate);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION ElementProperties Echo{{{1*/
+void  ElementProperties::Echo(void){
+
+	int i;
+	
+	printf("   h=[\n"); for(i=0;i<numnodes;i++)printf("%g ",this->h[i]);printf("]\n");
+	printf("   s=[\n"); for(i=0;i<numnodes;i++)printf("%g ",this->s[i]);printf("]\n");
+	printf("   b=[\n"); for(i=0;i<numnodes;i++)printf("%g ",this->b[i]);printf("]\n");
+	printf("   melting=[\n"); for(i=0;i<numnodes;i++)printf("%g ",this->melting[i]);printf("]\n");
+	printf("   accumulation=[\n"); for(i=0;i<numnodes;i++)printf("%g ",this->accumulation[i]);printf("]\n");
+	printf("   geothermalflux=[\n"); for(i=0;i<numnodes;i++)printf("%g ",this->geothermalflux[i]);printf("]\n");
+	printf("   friction_type: %i\n",friction_type);
+	printf("   p: %g\n",p);
+	printf("   q: %g\n",q);
+	printf("   shelf: %i\n",shelf);
+	printf("   onbed: %i\n",onbed);
+	printf("   onwater: %i\n",onwater);
+	printf("   onsurface: %i\n",onsurface);
+	printf("   collapse: %i\n",collapse);
+	printf("   thermal_steadystate: %i\n",thermal_steadystate);
+}
+/*}}}*/
+/*FUNCTION ElementProperties DeepEcho{{{1*/
+void  ElementProperties::DeepEcho(void){
+	this->Echo();
+}
+/*}}}*/
+/*FUNCTION ElementProperties Spawn{{{1*/
+ElementProperties* ElementProperties::Spawn(int* indices, int numindices){
+
+	int i;
+	
+	int     sub_numnodes=0;
+	double* sub_h=NULL;
+	double* sub_s=NULL;
+	double* sub_b=NULL;
+	double* sub_k=NULL;
+	double* sub_melting=NULL;
+	double* sub_accumulation=NULL;
+	double* sub_geothermalflux=NULL;
+
+	int     sub_friction_type;
+	double  sub_p;
+	double  sub_q;
+	int     sub_shelf;
+	int     sub_onbed;
+	bool    sub_onwater;
+	int     sub_onsurface;
+	int     sub_collapse;
+	int     sub_thermal_steadystate;
+
+	ElementProperties* sub_properties = NULL;
+
+	sub_numnodes=numindices;
+
+	/*go pickup the correct objects, for the correct ids: */
+	if(this->h)sub_h=(double*)xmalloc(numindices*sizeof(double));
+	if(this->s)sub_s=(double*)xmalloc(numindices*sizeof(double));
+	if(this->b)sub_b=(double*)xmalloc(numindices*sizeof(double));
+	if(this->k)sub_k=(double*)xmalloc(numindices*sizeof(double));
+	if(this->melting)sub_melting=(double*)xmalloc(numindices*sizeof(double));
+	if(this->accumulation)sub_accumulation=(double*)xmalloc(numindices*sizeof(double));
+	if(this->geothermalflux)sub_geothermalflux=(double*)xmalloc(numindices*sizeof(double));
+
+	for(i=0;i<numindices;i++){
+		if(this->h)sub_h[i]=this->h[indices[i]];
+		if(this->s)sub_s[i]=this->s[indices[i]];
+		if(this->b)sub_b[i]=this->b[indices[i]];
+		if(this->k)sub_k[i]=this->k[indices[i]];
+		if(this->melting)sub_melting[i]=this->melting[indices[i]];
+		if(this->accumulation)sub_accumulation[i]=this->accumulation[indices[i]];
+		if(this->geothermalflux)sub_geothermalflux[i]=this->geothermalflux[indices[i]];
+	}
+
+	sub_friction_type=this->friction_type;
+	sub_p=this->p;
+	sub_q=this->q;
+	sub_shelf=this->shelf;
+	sub_onbed=this->onbed;
+	sub_onwater=this->onwater;
+	sub_onsurface=this->onsurface;
+	sub_collapse=this->collapse;
+	sub_thermal_steadystate=this->thermal_steadystate;
+
+	sub_properties=new ElementProperties(numindices,sub_h, sub_s, sub_b, sub_k, sub_melting, sub_accumulation, sub_geothermalflux, sub_friction_type, sub_p, sub_q, sub_shelf, sub_onbed, sub_onwater, sub_onsurface, sub_collapse, sub_thermal_steadystate);
+
+
+	xfree((void**)&sub_h);
+	xfree((void**)&sub_s);
+	xfree((void**)&sub_b);
+	xfree((void**)&sub_k);
+	xfree((void**)&sub_melting);
+	xfree((void**)&sub_accumulation);
+	xfree((void**)&sub_geothermalflux);
+
+	return sub_properties;
+
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/ElementProperties.h
===================================================================
--- /issm/trunk/src/c/objects/ElementProperties.h	(revision 3383)
+++ /issm/trunk/src/c/objects/ElementProperties.h	(revision 3383)
@@ -0,0 +1,49 @@
+/*!\file: ElementProperties.h
+ * \brief prototype for ElementProperties.h
+ */ 
+
+#ifndef _ELEMENTPROPERTIES_H_
+#define  _ELEMENTPROPERTIES_H_
+
+class ElementProperties{
+	
+	public:
+
+		/*nodal property values: */
+		int     numnodes;
+		double*  h;
+		double*  s;
+		double*  b;
+		double*  k;
+		double*  melting;
+		double*  accumulation;
+		double*  geothermalflux;
+		
+		/*element property values: */
+		int     friction_type;
+		double  p;
+		double  q;
+		int     shelf;
+		int     onbed;
+		bool    onwater;
+		int     onsurface;
+		int     collapse;
+		int     thermal_steadystate;
+
+		ElementProperties();
+		ElementProperties(int numnodes, double* h, double* s, double* b, double* k, double* melting, double* accumulation, double* geothermalflux, int friction_type, double p, double q, int shelf, int onbed, bool onwater, int onsurface, int collapse, int thermal_steadystate);
+		ElementProperties(ElementProperties* properties);
+		~ElementProperties();
+		
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		void  Demarshall(char** pmarshalled_dataset);
+		void  copy(ElementProperties* properties);
+		void  Echo(void); 
+		void  DeepEcho(void); 
+		ElementProperties* Spawn(int* indices, int numindices);
+
+};
+#endif //ifndef _ELEMENTPROPERTIES_H_
+
+		
Index: /issm/trunk/src/c/objects/Hook.cpp
===================================================================
--- /issm/trunk/src/c/objects/Hook.cpp	(revision 3383)
+++ /issm/trunk/src/c/objects/Hook.cpp	(revision 3383)
@@ -0,0 +1,319 @@
+/*!\file Hook.cpp
+ * \brief: implementation of the Hook object: see Hook.h for more explanations.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include <string.h>
+#include "../EnumDefinitions/EnumDefinitions.h"
+#include "./ParameterInputs.h"
+#include "../shared/shared.h"
+#include "../include/typedefs.h"
+#include "../include/macros.h"
+#include "./Hook.h"
+
+
+/*FUNCTION Hook default constructor {{{1*/
+Hook::Hook(){
+	this->num=0;
+	this->objects=NULL;
+	this->ids=NULL;
+	this->offsets=NULL;
+	return;
+}
+/*}}}*/
+/*FUNCTION Hook constructor {{{1*/
+Hook::Hook(int* ids, int num){
+
+	int i;
+	this->num=num;
+	
+	/*Allocate: */
+	this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
+	this->ids=(int*)xmalloc(this->num*sizeof(int));
+	this->offsets=(int*)xmalloc(this->num*sizeof(int));
+
+	/*Copy ids: */
+	for (i=0;i<this->num;i++){
+		this->ids[i]=ids[i];
+	}
+}
+/*}}}*/
+/*FUNCTION Hook sort of copy constructor {{{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 copy constructor {{{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->GetIds();
+	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 destructeur{{{1*/
+Hook::~Hook(){
+	/*deallocate: */
+	xfree((void**)&this->objects);
+	xfree((void**)&this->ids);
+	xfree((void**)&this->offsets);
+	return;
+}
+/*}}}*/
+/*FUNCTION Hook Marshall{{{1*/
+void Hook::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_type=0;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum type of Hook: */
+	enum_type=HookEnum();
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	
+	/*marshall Hook data: */
+	memcpy(marshalled_dataset,&num,sizeof(num));marshalled_dataset+=sizeof(num);
+	for(i=0;i<num;i++){
+		memcpy(marshalled_dataset,&this->ids[i],sizeof(int));marshalled_dataset+=sizeof(int);
+		memcpy(marshalled_dataset,&this->offsets[i],sizeof(int));marshalled_dataset+=sizeof(int);
+	}
+
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION Hook MarshallSize{{{1*/
+int Hook::MarshallSize(){
+
+	return 
+		sizeof(num)+
+		num*sizeof(int)+
+		num*sizeof(int)+
+		sizeof(int); //sizeof(int) for enum type
+}
+/*}}}*/
+/*FUNCTION Hook Demarshall{{{1*/
+void Hook::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+
+	memcpy(&num,marshalled_dataset,sizeof(num));marshalled_dataset+=sizeof(num);
+	
+	/*allocate: */
+	this->ids=(int*)xmalloc(num*sizeof(int));
+	this->offsets=(int*)xmalloc(num*sizeof(int));
+	
+	/*demarshall allocated ids and offsets: */
+	for (i=0;i<num;i++){
+		memcpy(&this->ids[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
+		memcpy(&this->offsets[i],marshalled_dataset,sizeof(int));marshalled_dataset+=sizeof(int);
+	}
+
+	/*nullify object pointers */
+	this->objects=(Object**)xmalloc(num*sizeof(Object*));
+	for (i=0;i<num;i++){
+		this->objects[i]=NULL;
+	}
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION Hook deliver{{{1*/
+Object* Hook::delivers(void){
+	
+	/*first, check that we only have one T object in our object list: */
+	if (this->num!=1) ISSMERROR(exprintf("%s%i%s\n"," trying to delivery a single hook object when hook holds ",this->num," objects"));
+
+	/*check NULL: */
+	if (this->objects=NULL)ISSMERROR("hook is not pointing to any object, objects pointer is NULL");
+
+	return *objects;
+}
+
+/*}}}*/
+/*FUNCTION Hook deliver{{{1*/
+Object** Hook::deliverp(void){
+	return objects;
+}
+/*}}}*/
+/*FUNCTION Hook ResolvePointers{{{1*/
+void Hook::configure(DataSet* dataset){
+
+	/*intermediary: */
+	Object* object=NULL;
+	int i;
+
+	for(i=0;i<this->num;i++){
+
+		/*is this object id -1? If so, drop this search, it was not requested: */
+		if (this->ids[i]==-1)continue;
+
+		/*Check whether existing this->objects are correct: */
+		if(this->objects[i]){
+			if(this->objects[i]->GetId()==this->ids[i]) continue; //this node is good.
+			else this->objects[i]=NULL; //this node was incorrect, reset it.
+		}
+
+		/*May be the object this->offsets into this->objects are valid?: */
+		if(this->offsets[i]!=UNDEF){
+			/* Look at the this->offsets[i]'th node in the nodes dataset. If it has the correct id, 
+			 * we are good: */
+			object=(Object*)dataset->GetObjectByOffset(this->offsets[i]);
+			if (object->GetId()==this->ids[i]){
+				this->objects[i]=object;
+				continue;
+			}
+			else this->offsets[i]=UNDEF; //object offset was wrong, reset it.
+		}
+
+		/*Now, for this->objects that did not get resolved, and for which we have no offset, chase them in the dataset, by id: */
+		if(this->objects[i]==NULL){
+			this->objects[i]=(Object*)dataset->GetObjectById(this->offsets+i,this->ids[i]); //remember the offset for later on.
+			/*check the id is correct!: */
+			if (this->objects[i]->GetId()!=this->ids[i])ISSMERROR(exprintf("%s%i%s%i%s"," wrong id: ",this->objects[i]->GetId()," vs ",this->ids[i],"  in resolved pointer!"));
+		}
+	}
+}
+/*}}}*/
+/*FUNCTION Hook echo{{{1*/
+void Hook::Echo(void){
+
+	int i;
+	if (num){
+		printf("Hook: \n");
+		printf("  num=%i\n",this->num);
+		printf("  ids:\n    ");
+		for (i=0;i<this->num;i++){
+			printf("%i ",this->ids[i]);
+		}
+		printf("\n   offsets:\n   ");
+		for (i=0;i<this->num;i++){
+			printf("%i ",this->offsets[i]);
+		}
+	}
+	else{
+		printf("Hook: num=0 \n");
+	}
+}
+/*}}}*/
+/*FUNCTION Hook deep echo{{{1*/
+void Hook::DeepEcho(void){
+
+	int i;
+	if (num){
+		printf("Hook: \n");
+		printf("  num=%i\n",this->num);
+		printf("  ids:\n    ");
+		for (i=0;i<this->num;i++){
+			printf("%i ",this->ids[i]);
+		}
+		printf("\n   offsets:\n   ");
+		for (i=0;i<this->num;i++){
+			printf("%i ",this->offsets[i]);
+		}
+		printf("\n   objects:\n   ");
+		for (i=0;i<this->num;i++){
+			printf("      object %i\n",i);
+			objects[i]->Echo();
+		}
+	}
+	else{
+		printf("Hook: num=0 \n");
+	}
+}
+/*}}}*/
+/*FUNCTION Hook Spawn{{{1*/
+Hook* Hook::Spawn(int* indices, int numindices){
+
+	int i;
+	Object** subobjects=NULL;
+	int       subnum;
+	int*      suboffsets=NULL;
+	int*      subids=NULL;
+
+	/*go pickup the correct objects, ids and offsets :*/
+	subnum=numindices;
+
+	subobjects=(Object**)xmalloc(subnum*sizeof(Object*));
+	subids=(int*)xmalloc(subnum*sizeof(int));
+	suboffsets=(int*)xmalloc(subnum*sizeof(int));
+
+	if(subnum){
+		for(i=0;i<subnum;i++){
+			subobjects[i]=this->objects[indices[i]];
+			subids[i]=this->ids[indices[i]];
+			suboffsets[i]=this->offsets[indices[i]];
+		}
+	}
+	else ISSMERROR("Trying to spawn an empty ElementProperties!");
+
+	return new Hook(subobjects,subids,suboffsets,subnum);
+}
+/*}}}*/
+/*FUNCTION Hook GetObjects{{{1*/
+Object** Hook::GetObjects(void){
+	return this->objects;
+}
+/*}}}*/
+/*FUNCTION Hook GetIds{{{1*/
+int* Hook::GetIds(void){
+	return this->ids;
+}
+/*}}}*/
+/*FUNCTION Hook GetOffsets{{{1*/
+int* Hook::GetOffsets(void){
+	return this->offsets;
+}
+/*}}}*/
+/*FUNCTION Hook GetNum{{{1*/
+int Hook::GetNum(void){
+	return this->num;
+}
+/*}}}*/
Index: /issm/trunk/src/c/objects/Hook.h
===================================================================
--- /issm/trunk/src/c/objects/Hook.h	(revision 3383)
+++ /issm/trunk/src/c/objects/Hook.h	(revision 3383)
@@ -0,0 +1,51 @@
+/*!\file Hook.h
+ * \brief: header file for hook object.
+ * A hook is a class  that can store the id, offset, and object corresponding to this id and offset into a dataset.
+ * For example, an element has a hook to its nodes. A node has a hook to its vertex.  The hook abstracts the need for having
+ * ids and offsets (necesarry for proper configuration of an object) in our objects. 
+ */
+
+#ifndef _HOOK_H_
+#define _HOOK_H_
+
+#include "./Object.h"
+#include "./../DataSet/DataSet.h"
+#include "../toolkits/toolkits.h"
+
+class DataSet;
+class Object;
+
+class Hook{
+
+	private: 
+
+		int	   num; //number of objects being hooked onto
+		Object**	   objects; //list of object pointers. we do not allocate objects, just a list a pointers, that will get to point to the real objects from a dataset.
+		int*   ids;     //list of object ids, to go look for them in datasets.
+		int*   offsets;  //list of object offsets into datasets, to speed up lookup.
+
+	public:
+
+		Hook();
+		Hook(int* ids, int num);
+		Hook(Object** objects, int* ids, int* offsets,int num);
+		Hook(Hook* hook);
+		~Hook();
+		void       Marshall(char** pmarshalled_dataset);
+		int        MarshallSize();
+		void       Demarshall(char** pmarshalled_dataset);
+		Object*    delivers(void); //single object deliver
+		Object**   deliverp(void); //deliver all objects
+		void       configure(DataSet* dataset);
+		void       Echo(void);
+		void       DeepEcho(void);
+		Hook*      Spawn(int* indices, int numindices);
+		Object**   GetObjects(void);
+		int*       GetIds(void);
+		int*       GetOffsets(void);
+		int        GetNum(void);
+
+
+};
+
+#endif  /* _HOOK_H_ */
Index: /issm/trunk/src/c/objects/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Penta.cpp	(revision 3382)
+++ /issm/trunk/src/c/objects/Penta.cpp	(revision 3383)
@@ -18,49 +18,20 @@
 
 /*Object constructors and destructor*/
-/*FUNCTION Penta constructor {{{1*/
+/*FUNCTION Penta default constructor {{{1*/
 Penta::Penta(){
 	return;
 }
 /*}}}*/
-/*FUNCTION Penta creation {{{1*/
-Penta::Penta( int penta_id, int penta_mid, int penta_mparid, int penta_numparid, int penta_node_ids[6], double penta_h[6], double penta_s[6], double penta_b[6], double penta_k[6], int penta_friction_type, 
-			double penta_p, double penta_q, int penta_shelf, int penta_onbed, int penta_onsurface,  int penta_collapse, double penta_melting[6], double penta_accumulation[6], double penta_geothermalflux[6], 
-			int penta_thermal_steadystate,bool penta_onwater){
-
-	int i;
-
-	id = penta_id;
-	mid = penta_mid; 
-	mparid = penta_mparid; 
-	numparid=penta_numparid;
-
-	for(i =0;i<6;i++){
-		node_ids[i] = penta_node_ids[i]; 
-		node_offsets[i]=UNDEF;
-		nodes[i]=NULL;
-		h[i] = penta_h[i]; 
-		s[i] = penta_s[i]; 
-		b[i] = penta_b[i]; 
-		k[i] = penta_k[i]; 
-		melting[i] = penta_melting[i]; 
-		accumulation[i] = penta_accumulation[i] ;
-		geothermalflux[i] = penta_geothermalflux[i]; 
-	}
-	matice=NULL;
-	matice_offset=UNDEF;
-	matpar=NULL;
-	matpar_offset=UNDEF;
-	numpar=NULL;
-	numpar_offset=UNDEF;
-
-	friction_type = penta_friction_type; 
-	p = penta_p; 
-	q = penta_q; 
-	shelf = penta_shelf; 
-	onbed = penta_onbed; 
-	onwater = penta_onwater; 
-	onsurface = penta_onsurface; 
-	collapse = penta_collapse; 
-	thermal_steadystate = penta_thermal_steadystate;
+/*FUNCTION Penta constructor {{{1*/
+Penta::Penta(int penta_id,int* penta_node_ids, int penta_matice_id, int penta_matpar_id, int penta_numpar_id, ElementProperties* pentaproperties): 
+	hnodes(penta_node_ids,3),
+	hmatice(&penta_matice_id,1),
+	hmatpar(&penta_matpar_id,1),
+	hnumpar(&penta_numpar_id,1),
+	properties(pentaproperties)
+{
+
+	/*all the initialization has been done by the initializer, just fill in the id: */
+	this->id=penta_id;
 
 	return;
@@ -91,32 +62,13 @@
 	/*marshall Penta data: */
 	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid);
-	memcpy(marshalled_dataset,&mparid,sizeof(mparid));marshalled_dataset+=sizeof(mparid);
-	memcpy(marshalled_dataset,&node_ids,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids);
-	memcpy(marshalled_dataset,&nodes,sizeof(nodes));marshalled_dataset+=sizeof(nodes);
-	memcpy(marshalled_dataset,&node_offsets,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets);
-	memcpy(marshalled_dataset,&matice,sizeof(matice));marshalled_dataset+=sizeof(matice);
-	memcpy(marshalled_dataset,&matice_offset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset);
-	memcpy(marshalled_dataset,&matpar,sizeof(matpar));marshalled_dataset+=sizeof(matpar);
-	memcpy(marshalled_dataset,&matpar_offset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset);
-	memcpy(marshalled_dataset,&numparid,sizeof(numparid));marshalled_dataset+=sizeof(numparid);
-	memcpy(marshalled_dataset,&numpar,sizeof(numpar));marshalled_dataset+=sizeof(numpar);
-	memcpy(marshalled_dataset,&numpar_offset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset);
-	memcpy(marshalled_dataset,&h,sizeof(h));marshalled_dataset+=sizeof(h);
-	memcpy(marshalled_dataset,&s,sizeof(s));marshalled_dataset+=sizeof(s);
-	memcpy(marshalled_dataset,&b,sizeof(b));marshalled_dataset+=sizeof(b);
-	memcpy(marshalled_dataset,&k,sizeof(k));marshalled_dataset+=sizeof(k);
-	memcpy(marshalled_dataset,&friction_type,sizeof(friction_type));marshalled_dataset+=sizeof(friction_type);
-	memcpy(marshalled_dataset,&p,sizeof(p));marshalled_dataset+=sizeof(p);
-	memcpy(marshalled_dataset,&q,sizeof(q));marshalled_dataset+=sizeof(q);
-	memcpy(marshalled_dataset,&shelf,sizeof(shelf));marshalled_dataset+=sizeof(shelf);
-	memcpy(marshalled_dataset,&onbed,sizeof(onbed));marshalled_dataset+=sizeof(onbed);
-	memcpy(marshalled_dataset,&onwater,sizeof(onwater));marshalled_dataset+=sizeof(onwater);
-	memcpy(marshalled_dataset,&onsurface,sizeof(onsurface));marshalled_dataset+=sizeof(onsurface);
-	memcpy(marshalled_dataset,&collapse,sizeof(collapse));marshalled_dataset+=sizeof(collapse);
-	memcpy(marshalled_dataset,&melting,sizeof(melting));marshalled_dataset+=sizeof(melting);
-	memcpy(marshalled_dataset,&accumulation,sizeof(accumulation));marshalled_dataset+=sizeof(accumulation);
-	memcpy(marshalled_dataset,&geothermalflux,sizeof(geothermalflux));marshalled_dataset+=sizeof(geothermalflux);
-	memcpy(marshalled_dataset,&thermal_steadystate,sizeof(thermal_steadystate));marshalled_dataset+=sizeof(thermal_steadystate);
+
+	/*Marshall hooks: */
+	hnodes.Marshall(&marshalled_dataset);
+	hmatice.Marshall(&marshalled_dataset);
+	hmatpar.Marshall(&marshalled_dataset);
+	hnumpar.Marshall(&marshalled_dataset);
+
+	/*Marshall properties: */
+	properties.Marshall(&marshalled_dataset);
 
 	*pmarshalled_dataset=marshalled_dataset;
@@ -126,35 +78,12 @@
 /*FUNCTION MarshallSize {{{1*/
 int   Penta::MarshallSize(){
-
-	return sizeof(id)+
-	  sizeof(mid)+
-	  sizeof(mparid)+
-	  sizeof(node_ids)+
-	  sizeof(nodes)+
-	  sizeof(node_offsets)+
-	  sizeof(matice)+
-	  sizeof(matice_offset)+
-	  sizeof(matpar)+
-	  sizeof(matpar_offset)+
-	  +sizeof(numparid)+
-	  +sizeof(numpar)+
-	  +sizeof(numpar_offset)+
-	  sizeof(h)+
-	  sizeof(s)+
-	  sizeof(b)+
-	  sizeof(k)+
-	  sizeof(friction_type)+
-	  sizeof(p)+
-	  sizeof(q)+
-	  sizeof(shelf)+
-	  sizeof(onbed)+
-	  sizeof(onwater)+
-	  sizeof(onsurface)+
-	  sizeof(collapse)+
-	  sizeof(melting)+
-	  sizeof(accumulation)+
-	  sizeof(geothermalflux)+
-	  sizeof(thermal_steadystate) +
-	  sizeof(int); //sizeof(int) for enum type
+	
+	return sizeof(id)
+		+hnodes.MarshallSize()
+		+hmatice.MarshallSize()
+		+hmatpar.MarshallSize()
+		+hnumpar.MarshallSize()
+		+properties.MarshallSize()
+		+sizeof(int); //sizeof(int) for enum type
 }
 /*}}}*/
@@ -162,6 +91,6 @@
 void  Penta::Demarshall(char** pmarshalled_dataset){
 
-	int i;
 	char* marshalled_dataset=NULL;
+	int   i;
 
 	/*recover marshalled_dataset: */
@@ -172,42 +101,107 @@
 
 	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid);
-	memcpy(&mparid,marshalled_dataset,sizeof(mparid));marshalled_dataset+=sizeof(mparid);
-	memcpy(&node_ids,marshalled_dataset,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids);
-	memcpy(&nodes,marshalled_dataset,sizeof(nodes));marshalled_dataset+=sizeof(nodes);
-	memcpy(&node_offsets,marshalled_dataset,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets);
-	memcpy(&matice,marshalled_dataset,sizeof(matice));marshalled_dataset+=sizeof(matice);
-	memcpy(&matice_offset,marshalled_dataset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset);
-	memcpy(&matpar,marshalled_dataset,sizeof(matpar));marshalled_dataset+=sizeof(matpar);
-	memcpy(&matpar_offset,marshalled_dataset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset);
-	memcpy(&numparid,marshalled_dataset,sizeof(numparid));marshalled_dataset+=sizeof(numparid);
-	memcpy(&numpar,marshalled_dataset,sizeof(numpar));marshalled_dataset+=sizeof(numpar);
-	memcpy(&numpar_offset,marshalled_dataset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset);
-	memcpy(&h,marshalled_dataset,sizeof(h));marshalled_dataset+=sizeof(h);
-	memcpy(&s,marshalled_dataset,sizeof(s));marshalled_dataset+=sizeof(s);
-	memcpy(&b,marshalled_dataset,sizeof(b));marshalled_dataset+=sizeof(b);
-	memcpy(&k,marshalled_dataset,sizeof(k));marshalled_dataset+=sizeof(k);
-	memcpy(&friction_type,marshalled_dataset,sizeof(friction_type));marshalled_dataset+=sizeof(friction_type);
-	memcpy(&p,marshalled_dataset,sizeof(p));marshalled_dataset+=sizeof(p);
-	memcpy(&q,marshalled_dataset,sizeof(q));marshalled_dataset+=sizeof(q);
-	memcpy(&shelf,marshalled_dataset,sizeof(shelf));marshalled_dataset+=sizeof(shelf);
-	memcpy(&onbed,marshalled_dataset,sizeof(onbed));marshalled_dataset+=sizeof(onbed);
-	memcpy(&onwater,marshalled_dataset,sizeof(onwater));marshalled_dataset+=sizeof(onwater);
-	memcpy(&onsurface,marshalled_dataset,sizeof(onsurface));marshalled_dataset+=sizeof(onsurface);
-	memcpy(&collapse,marshalled_dataset,sizeof(collapse));marshalled_dataset+=sizeof(collapse);
-	memcpy(&melting,marshalled_dataset,sizeof(melting));marshalled_dataset+=sizeof(melting);
-	memcpy(&accumulation,marshalled_dataset,sizeof(accumulation));marshalled_dataset+=sizeof(accumulation);
-	memcpy(&geothermalflux,marshalled_dataset,sizeof(geothermalflux));marshalled_dataset+=sizeof(geothermalflux);
-	memcpy(&thermal_steadystate,marshalled_dataset,sizeof(thermal_steadystate));marshalled_dataset+=sizeof(thermal_steadystate);
-
-	/*nodes and materials are not pointing to correct objects anymore:*/
-	for(i=0;i<6;i++)nodes[i]=NULL;
-	matice=NULL;
-	matpar=NULL;
-	numpar=NULL;
+
+	/*demarshall hooks: */
+	hnodes.Demarshall(&marshalled_dataset);
+	hmatice.Demarshall(&marshalled_dataset);
+	hmatpar.Demarshall(&marshalled_dataset);
+	hnumpar.Demarshall(&marshalled_dataset);
+
+	/*demarshall properties: */
+	properties.Demarshall(&marshalled_dataset);
 
 	/*return: */
 	*pmarshalled_dataset=marshalled_dataset;
 	return;
+}
+/*}}}*/
+
+/*Object processing: */
+/*FUNCTION Echo{{{1*/
+
+void Penta::Echo(void){
+
+	printf("Penta:\n");
+	printf("   id: %i\n",id);
+	hnodes.Echo();
+	hmatice.Echo();
+	hmatpar.Echo();
+	hnumpar.Echo();
+	properties.Echo();
+
+	return;
+}
+/*}}}*/
+/*FUNCTION DeepEcho{{{1*/
+
+void Penta::DeepEcho(void){
+
+	printf("Penta:\n");
+	printf("   id: %i\n",id);
+	hnodes.DeepEcho();
+	hmatice.DeepEcho();
+	hmatpar.DeepEcho();
+	hnumpar.DeepEcho();
+	properties.DeepEcho();
+
+	return;
+}
+/*}}}*/
+/*FUNCTION Configure {{{1*/
+void  Penta::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){
+
+	int i;
+
+	DataSet* loadsin=NULL;
+	DataSet* nodesin=NULL;
+	DataSet* materialsin=NULL;
+	DataSet* parametersin=NULL;
+
+	/*Recover pointers :*/
+	loadsin=(DataSet*)ploadsin;
+	nodesin=(DataSet*)pnodesin;
+	materialsin=(DataSet*)pmaterialsin;
+	parametersin=(DataSet*)pparametersin;
+
+	/*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);
+	hmatice.configure(materialsin);
+	hmatpar.configure(materialsin);
+	hnumpar.configure(parametersin);
+
+}
+/*}}}*/
+/*FUNCTION SpawnTria {{{1*/
+void*  Penta::SpawnTria(int g0, int g1, int g2){
+
+	/*out of grids g0,g1 and g2 from Penta, build a tria element: */
+	Tria* tria=NULL;
+	int indices[3];
+	Hook* tria_hnodes=NULL;
+	Hook* tria_hmatice=NULL;
+	Hook* tria_hmatpar=NULL;
+	Hook* tria_hnumpar=NULL;
+	ElementProperties* tria_properties=NULL;
+
+	indices[0]=g0;
+	indices[1]=g1;
+	indices[2]=g2;
+
+	tria_hnodes=this->hnodes.Spawn(indices,3);
+	tria_hmatice=this->hmatice.Spawn(indices,3);
+	tria_hmatpar=this->hmatpar.Spawn(indices,3);
+	tria_hnumpar=this->hnumpar.Spawn(indices,3);
+	tria_properties=(ElementProperties*)this->properties.Spawn(indices,3);
+
+	tria=new Tria(this->id,tria_hnodes,tria_hmatice,tria_hmatpar,tria_hnumpar,tria_properties);
+
+	delete tria_hnodes;
+	delete tria_hmatice;
+	delete tria_hmatpar;
+	delete tria_hnumpar;
+	delete tria_properties;
+
+	return tria;
 }
 /*}}}*/
@@ -224,6 +218,14 @@
 	double       xyz_list[numgrids][3];
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Get node data: */
@@ -240,37 +242,9 @@
 	g=matpar->GetG();
 	for(i=0;i<numgrids;i++){
-		pressure[i]=rho_ice*g*(s[i]-xyz_list[i][2]);
+		pressure[i]=rho_ice*g*(this->properties.s[i]-xyz_list[i][2]);
 	}
 
 	/*plug local pressure values into global pressure vector: */
 	VecSetValues(pg,numgrids,doflist,(const double*)pressure,INSERT_VALUES);
-
-}
-/*}}}*/
-/*FUNCTION Configure {{{1*/
-void  Penta::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){
-
-	int i;
-
-	DataSet* loadsin=NULL;
-	DataSet* nodesin=NULL;
-	DataSet* materialsin=NULL;
-	DataSet* parametersin=NULL;
-
-	/*Recover pointers :*/
-	loadsin=(DataSet*)ploadsin;
-	nodesin=(DataSet*)pnodesin;
-	materialsin=(DataSet*)pmaterialsin;
-	parametersin=(DataSet*)pparametersin;
-
-	/*Link this element with its nodes, ie find pointers to the nodes in the nodes dataset.: */
-	ResolvePointers((Object**)nodes,node_ids,node_offsets,6,nodesin);
-
-	/*Same for materials: */
-	ResolvePointers((Object**)&matice,&mid,&matice_offset,1,materialsin);
-	ResolvePointers((Object**)&matpar,&mparid,&matpar_offset,1,materialsin);
-
-	/*Same for numpar: */
-	ResolvePointers((Object**)&numpar,&numparid,&numpar_offset,1,parametersin);
 
 }
@@ -288,13 +262,13 @@
 
 	/*If on water, return 0: */
-	if(onwater)return 0;
+	if(this->properties.onwater)return 0;
 
 	/*Bail out if this element if:
 	 * -> Non collapsed and not on the surface
 	 * -> collapsed (2d model) and not on bed) */
-	if ((!collapse && !onsurface) || (collapse && !onbed)){
+	if ((!this->properties.collapse && !this->properties.onsurface) || (this->properties.collapse && !this->properties.onbed)){
 		return 0;
 	}
-	else if (collapse){
+	else if (this->properties.collapse){
 
 		/*This element should be collapsed into a tria element at its base. Create this tria element, 
@@ -379,8 +353,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -400,8 +374,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -498,6 +472,16 @@
 	Tria*  tria=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
+
 	/*If on water, skip stiffness: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*recover pointers: */
@@ -509,10 +493,10 @@
 
 
-	if ((collapse==1) && (onbed==0)){
+	if ((this->properties.collapse==1) && (this->properties.onbed==0)){
 		/*This element should be collapsed, but this element is not on the bedrock, therefore all its 
 		 * dofs have already been frozen! Do nothing: */
 		return;
 	}
-	else if ((collapse==1) && (onbed==1)){
+	else if ((this->properties.collapse==1) && (this->properties.onbed==1)){
 
 		/*This element should be collapsed into a tria element at its base. Create this tria element, 
@@ -643,5 +627,5 @@
 
 		//Deal with 2d friction at the bedrock interface
-		if((onbed && !shelf)){
+		if((this->properties.onbed && !this->properties.shelf)){
 
 			/*Build a tria element using the 3 grids of the base of the penta. Then use 
@@ -744,6 +728,18 @@
 	ParameterInputs* inputs=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	/*If on water, skip stiffness: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover pointers: */
@@ -831,5 +827,5 @@
 	}
 
-	if((onbed==1) && (shelf==0)){
+	if((this->properties.onbed==1) && (this->properties.shelf==0)){
 
 		/*Build alpha2_list used by drag stiffness matrix*/
@@ -843,10 +839,10 @@
 		friction->rho_ice=matpar->GetRhoIce();
 		friction->rho_water=matpar->GetRhoWater();
-		friction->K=&k[0];
-		friction->bed=&b[0];
-		friction->thickness=&h[0];
+		friction->K=&this->properties.k[0];
+		friction->bed=&this->properties.b[0];
+		friction->thickness=&this->properties.h[0];
 		friction->velocities=&vxvyvz_list[0][0];
-		friction->p=p;
-		friction->q=q;
+		friction->p=this->properties.p;
+		friction->q=this->properties.q;
 		friction->analysis_type=analysis_type;
 
@@ -926,5 +922,5 @@
 			}
 		}
-	} //if ( (onbed==1) && (shelf==0))
+	} //if ( (this->properties.onbed==1) && (shelf==0))
 
 	/*Reduce the matrix */
@@ -990,4 +986,10 @@
 	double  DL_scalar;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+
 	ParameterInputs* inputs=NULL;
 
@@ -996,5 +998,5 @@
 
 	/*If on water, skip stiffness: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*recover pointers: */
@@ -1004,5 +1006,5 @@
 	/*If this element  is on the surface, we have a dynamic boundary condition that applies, as a stiffness 
 	 * matrix: */
-	if(onsurface){
+	if(this->properties.onsurface){
 		tria=(Tria*)SpawnTria(3,4,5); //nodes 3,4 and 5 are on the surface
 		tria->CreateKMatrixDiagnosticSurfaceVert(Kgg,inputs, analysis_type,sub_analysis_type);
@@ -1096,7 +1098,7 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
-
-	if (!onbed){
+	if(this->properties.onwater)return;
+
+	if (!this->properties.onbed){
 		return;
 	}
@@ -1118,8 +1120,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -1139,8 +1141,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -1227,4 +1229,9 @@
 	double     mixed_layer_capacity,thermal_exchange_velocity;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Numpar* numpar=NULL;
+
 	/*Collapsed formulation: */
 	Tria*  tria=NULL;
@@ -1232,5 +1239,10 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover pointers: */
@@ -1397,5 +1409,5 @@
 
 	//Ice/ocean heat exchange flux on ice shelf base 
-	if(onbed && shelf){
+	if(this->properties.onbed && this->properties.shelf){
 
 		tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
@@ -1467,8 +1479,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -1487,8 +1499,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -1545,12 +1557,20 @@
 	ParameterInputs* inputs=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+
 	/*Spawning: */
 	Tria* tria=NULL;
 
 	/*If on water, skip load: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
 
 
@@ -1559,10 +1579,10 @@
 	  the load vector. */
 
-	if ((collapse==1) && (onbed==0)){
+	if ((this->properties.collapse==1) && (this->properties.onbed==0)){
 		/*This element should be collapsed, but this element is not on the bedrock, therefore all its 
 		 * dofs have already been frozen! Do nothing: */
 		return;
 	}
-	else if ((collapse==1) && (onbed==1)){
+	else if ((this->properties.collapse==1) && (this->properties.onbed==1)){
 
 		/*This element should be collapsed into a tria element at its base. Create this tria element, 
@@ -1613,8 +1633,8 @@
 
 				/*Compute thickness at gaussian point: */
-				GetParameterValue(&thickness, &h[0],gauss_coord);
+				GetParameterValue(&thickness, &this->properties.h[0],gauss_coord);
 
 				/*Compute slope at gaussian point: */
-				GetParameterDerivativeValue(&slope[0], &s[0],&xyz_list[0][0], gauss_coord);
+				GetParameterDerivativeValue(&slope[0], &this->properties.s[0],&xyz_list[0][0], gauss_coord);
 
 				/* Get Jacobian determinant: */
@@ -1640,5 +1660,5 @@
 		} //for (ig1=0; ig1<num_area_gauss; ig1++)
 
-	} //else if ((collapse==1) && (onbed==1))
+	} //else if ((collapse==1) && (this->properties.onbed==1))
 
 	/*Add pe_g to global vector pg: */
@@ -1723,9 +1743,21 @@
 	Tria*            tria=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	/*If on water, skip load: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Set P_terms to 0: */
@@ -1822,5 +1854,5 @@
 
 	/*Deal with 2d friction at the bedrock interface: */
-	if ( (onbed==1) && (shelf==1)){
+	if ( (this->properties.onbed==1) && (this->properties.shelf==1)){
 
 		for(i=0;i<numgrids2d;i++){
@@ -1849,5 +1881,5 @@
 
 			/* Get bed at gaussian point */
-			GetParameterValue(&bed,&b[0],gauss_coord);
+			GetParameterValue(&bed,&this->properties.b[0],gauss_coord);
 
 			/*Get L matrix : */
@@ -1870,5 +1902,5 @@
 			}
 		}
-	} //if ( (onbed==1) && (shelf==1))
+	} //if ( (this->properties.onbed==1) && (this->properties.shelf==1))
 
 	/*Reduce the matrix */
@@ -1942,5 +1974,11 @@
 	int     dofs2[1]={1};
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
 	ParameterInputs* inputs=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
 
 	/*recover pointers: */
@@ -1948,9 +1986,9 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*If we are on the bedrock, spawn a tria on the bedrock, and use it to build the 
 	 *diagnostic base vertical stifness: */
-	if(onbed){
+	if(this->properties.onbed){
 		tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 are on the bedrock
 		tria->CreatePVectorDiagnosticBaseVert(pg,inputs, analysis_type,sub_analysis_type);
@@ -2049,8 +2087,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -2069,8 +2107,8 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Is this element on the bed? :*/
-	if(!onbed)return;
+	if(!this->properties.onbed)return;
 
 	/*Spawn Tria element from the base of the Penta: */
@@ -2155,9 +2193,19 @@
 	ParameterInputs* inputs=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -2249,5 +2297,5 @@
 
 	/* Ice/ocean heat exchange flux on ice shelf base */
-	if(onbed && shelf){
+	if(this->properties.onbed && this->properties.shelf){
 
 		tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
@@ -2257,5 +2305,5 @@
 
 	/* Geothermal flux on ice sheet base and basal friction */
-	if(onbed && !shelf){
+	if(this->properties.onbed && !this->properties.shelf){
 
 		tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
@@ -2274,39 +2322,4 @@
 }
 /*}}}*/
-/*FUNCTION DeepEcho {{{1*/
-void Penta::DeepEcho(void){
-
-	printf("Penta:\n");
-	printf("   id: %i\n",id);
-	printf("   mid: %i\n",mid);
-	printf("   mparid: %i\n",mparid);
-	printf("   numparid: %i\n",numparid);
-
-	printf("   node_ids=[%i,%i,%i,%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2],node_ids[3],node_ids[4],node_ids[5]);
-	printf("   node_offsets=[%i,%i,%i,%i,%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2],node_offsets[3],node_offsets[4],node_offsets[5]);
-	printf("   matice_offset=%i\n",matice_offset);
-	printf("   matpar_offset=%i\n",matpar_offset);
-
-	printf("   h=[%i,%i,%i,%i,%i,%i]\n",h[0],h[1],h[2],h[3],h[4],h[5]);
-	printf("   s=[%i,%i,%i,%i,%i,%i]\n",s[0],s[1],s[2],s[3],s[4],s[5]);
-	printf("   b=[%i,%i,%i,%i,%i,%i]\n",b[0],b[1],b[2],b[3],b[4],b[5]);
-	printf("   k=[%i,%i,%i,%i,%i,%i]\n",k[0],k[1],k[2],k[3],k[4],k[5]);
-
-	printf("   friction_type: %i\n",friction_type);
-	printf("   p: %g\n",p);
-	printf("   q: %g\n",q);
-	printf("   shelf: %i\n",shelf);
-	printf("   onbed: %i\n",onbed);
-	printf("   onwater: %i\n",onwater);
-	printf("   onsurface: %i\n",onsurface);
-	printf("   collapse: %i\n",collapse);
-
-	printf("   melting=[%i,%i,%i,%i,%i,%i]\n",melting[0],melting[1],melting[2],melting[3],melting[4],melting[5]);
-	printf("   accumulation=[%i,%i,%i,%i,%i,%i]\n",accumulation[0],accumulation[1],accumulation[2],accumulation[3],accumulation[4],accumulation[5]);
-	printf("   geothermalflux=[%i,%i,%i,%i,%i,%i]\n",geothermalflux[0],geothermalflux[1],geothermalflux[2],geothermalflux[3],geothermalflux[4],geothermalflux[5]);
-	printf("   thermal_steadystate: %i\n",thermal_steadystate);
-	return;
-}
-/*}}}*/
 /*FUNCTION Du {{{1*/
 void  Penta::Du(Vec du_g,void* inputs,int analysis_type,int sub_analysis_type){
@@ -2316,13 +2329,13 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*Bail out if this element if:
 	 * -> Non collapsed and not on the surface
 	 * -> collapsed (2d model) and not on bed) */
-	if ((!collapse && !onsurface) || (collapse && !onbed)){
+	if ((!this->properties.collapse && !this->properties.onsurface) || (this->properties.collapse && !this->properties.onbed)){
 		return;
 	}
-	else if (collapse){
+	else if (this->properties.collapse){
 
 		/*This element should be collapsed into a tria element at its base. Create this tria element, 
@@ -2342,39 +2355,4 @@
 }
 /*}}}*/
-/*FUNCTION Echo {{{1*/
-void Penta::Echo(void){
-
-	printf("Penta:\n");
-	printf("   id: %i\n",id);
-	printf("   mid: %i\n",mid);
-	printf("   mparid: %i\n",mparid);
-	printf("   numparid: %i\n",numparid);
-
-	printf("   node_ids=[%i,%i,%i,%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2],node_ids[3],node_ids[4],node_ids[5]);
-	printf("   node_offsets=[%i,%i,%i,%i,%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2],node_offsets[3],node_offsets[4],node_offsets[5]);
-	printf("   matice_offset=%i\n",matice_offset);
-	printf("   matpar_offset=%i\n",matpar_offset);
-
-	printf("   h=[%g,%g,%g,%g,%g,%g]\n",h[0],h[1],h[2],h[3],h[4],h[5]);
-	printf("   s=[%g,%g,%g,%g,%g,%g]\n",s[0],s[1],s[2],s[3],s[4],s[5]);
-	printf("   b=[%g,%g,%g,%g,%g,%g]\n",b[0],b[1],b[2],b[3],b[4],b[5]);
-	printf("   k=[%g,%g,%g,%g,%g,%g]\n",k[0],k[1],k[2],k[3],k[4],k[5]);
-
-	printf("   friction_type: %i\n",friction_type);
-	printf("   p: %g\n",p);
-	printf("   q: %g\n",q);
-	printf("   shelf: %i\n",shelf);
-	printf("   onbed: %i\n",onbed);
-	printf("   onwater: %i\n",onwater);
-	printf("   onsurface: %i\n",onsurface);
-	printf("   collapse: %i\n",collapse);
-
-	printf("   melting=[%g,%g,%g,%g,%g,%g]\n",melting[0],melting[1],melting[2],melting[3],melting[4],melting[5]);
-	printf("   accumulation=[%g,%g,%g,%g,%g,%g]\n",accumulation[0],accumulation[1],accumulation[2],accumulation[3],accumulation[4],accumulation[5]);
-	printf("   geothermalflux=[%g,%g,%g,%g,%g,%g]\n",geothermalflux[0],geothermalflux[1],geothermalflux[2],geothermalflux[3],geothermalflux[4],geothermalflux[5]);
-	printf("   thermal_steadystate: %i\n",thermal_steadystate);
-	return;
-}
-/*}}}*/
 /*FUNCTION Enum {{{1*/
 int Penta::Enum(void){
@@ -2394,8 +2372,14 @@
 	int   extrude=0;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+
 	/*Figure out if we should extrude for this element: */
 	if (iscollapsed){
 		/*From higher level, we are told to extrude only elements that have the collapse flag on: */
-		if (collapse)extrude=1;
+		if (this->properties.collapse)extrude=1;
 		else extrude=0;
 	}
@@ -2407,5 +2391,5 @@
 	/*Now, extrusion starts from the bed on, so double check this element is on 
 	 * the bedrock: */
-	if(onbed==0)extrude=0;
+	if(this->properties.onbed==0)extrude=0;
 
 	/*Go on and extrude field: */
@@ -2704,5 +2688,5 @@
 
 	int i;
-	for(i=0;i<6;i++)bed_list[i]=b[i];
+	for(i=0;i<6;i++)bed_list[i]=this->properties.b[i];
 
 }
@@ -2970,4 +2954,10 @@
 	int numberofdofspernode;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+
 	for(i=0;i<6;i++){
 		nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode);
@@ -2984,6 +2974,12 @@
 /*FUNCTION GetDofList1 {{{1*/
 void  Penta::GetDofList1(int* doflist){
-
+	
 	int i;
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+
 	for(i=0;i<6;i++){
 		doflist[i]=nodes[i]->GetDofList1();
@@ -3311,4 +3307,11 @@
 /*FUNCTION GetMatPar {{{1*/
 void* Penta::GetMatPar(){
+
+	/*dynamic objects pointed to by hooks: */
+	Matpar* matpar=NULL;
+
+	/*recover objects from hooks: */
+	matpar=(Matpar*)hmatpar.delivers();
+
 	return matpar;
 }
@@ -3564,6 +3567,15 @@
 /*FUNCTION GetNodes {{{1*/
 void  Penta::GetNodes(void** vpnodes){
+
 	int i;
-	Node** pnodes=(Node**)vpnodes;
+	Node** pnodes=NULL;
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	
+	/*virtual object: */
+	pnodes=(Node**)vpnodes;
 
 	for(i=0;i<6;i++){
@@ -3574,5 +3586,5 @@
 /*FUNCTION GetOnBed {{{1*/
 int Penta::GetOnBed(){
-	return onbed;
+	return this->properties.onbed;
 }
 /*}}}*/
@@ -3650,5 +3662,5 @@
 /*FUNCTION GetShelf {{{1*/
 int   Penta::GetShelf(){
-	return shelf;
+	return this->properties.shelf;
 }
 /*}}}*/
@@ -3753,5 +3765,5 @@
 
 	int i;
-	for(i=0;i<6;i++)thickness_list[i]=h[i];
+	for(i=0;i<6;i++)thickness_list[i]=this->properties.h[i];
 }
 /*}}}*/
@@ -3760,5 +3772,5 @@
 
 	/*If on water, skip grad (=0): */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	if (strcmp(control_type,"drag")==0){
@@ -3777,11 +3789,11 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*If on shelf, skip: */
-	if(shelf)return;
+	if(this->properties.shelf)return;
 
 	/*Bail out if this element does not touch the bedrock: */
-	if (!onbed) return;
+	if (!this->properties.onbed) return;
 
 	if (sub_analysis_type==HorizAnalysisEnum()){
@@ -3810,9 +3822,9 @@
 
 	/*If on water, skip: */
-	if(onwater)return;
-
-	if (collapse){
+	if(this->properties.onwater)return;
+
+	if (this->properties.collapse){
 		/*Bail out element if collapsed (2d) and not on bed*/
-		if (!onbed) return;
+		if (!this->properties.onbed) return;
 
 		/*This element should be collapsed into a tria element at its base. Create this tria element, 
@@ -3844,13 +3856,13 @@
 
 	/*If on water, return 0: */
-	if(onwater)return 0;
+	if(this->properties.onwater)return 0;
 
 	/*Bail out if this element if:
 	 * -> Non collapsed and not on the surface
 	 * -> collapsed (2d model) and not on bed) */
-	if ((!collapse && !onsurface) || (collapse && !onbed)){
+	if ((!this->properties.collapse && !this->properties.onsurface) || (this->properties.collapse && !this->properties.onbed)){
 		return 0;
 	}
-	else if (collapse){
+	else if (this->properties.collapse){
 
 		/*This element should be collapsed into a tria element at its base. Create this tria element, 
@@ -3964,74 +3976,4 @@
 }
 /*}}}*/
-/*FUNCTION SpawnTria {{{1*/
-void*  Penta::SpawnTria(int g0, int g1, int g2){
-
-	/*out of grids g0,g1 and g2 from Penta, build a tria element: */
-	Tria* tria=NULL;
-	double   tria_h[3];
-	double   tria_s[3];
-	double   tria_b[3];
-	double   tria_c[3];
-	double   tria_k[3];
-	double   tria_melting[3];
-	double   tria_accumulation[3];
-	double   tria_geothermalflux[3];
-
-	/*configuration: */
-	int tria_node_ids[3];
-	Node* tria_nodes[3];
-	int tria_node_offsets[3];
-
-	tria_h[0]=h[g0];
-	tria_h[1]=h[g1];
-	tria_h[2]=h[g2];
-
-	tria_s[0]=s[g0];
-	tria_s[1]=s[g1];
-	tria_s[2]=s[g2];
-
-	tria_b[0]=b[g0];
-	tria_b[1]=b[g1];
-	tria_b[2]=b[g2];
-
-	tria_k[0]=k[g0];
-	tria_k[1]=k[g1];
-	tria_k[2]=k[g2];
-
-	tria_melting[0]=melting[g0];
-	tria_melting[1]=melting[g1];
-	tria_melting[2]=melting[g2];
-
-	tria_accumulation[0]=accumulation[g0];
-	tria_accumulation[1]=accumulation[g1];
-	tria_accumulation[2]=accumulation[g2];
-
-	tria_geothermalflux[0]=geothermalflux[g0];
-	tria_geothermalflux[1]=geothermalflux[g1];
-	tria_geothermalflux[2]=geothermalflux[g2];
-
-	tria_node_ids[0]=node_ids[g0];
-	tria_node_ids[1]=node_ids[g1];
-	tria_node_ids[2]=node_ids[g2];
-
-	tria_nodes[0]=nodes[g0]; 
-	tria_nodes[1]=nodes[g1];
-	tria_nodes[2]=nodes[g2];
-
-	tria_node_offsets[0]=node_offsets[g0];
-	tria_node_offsets[1]=node_offsets[g1];
-	tria_node_offsets[2]=node_offsets[g2];
-
-	tria= new Tria(id,mid,mparid,numparid,tria_node_ids,tria_h,tria_s,tria_b,tria_k, tria_melting, tria_accumulation, tria_geothermalflux,friction_type,p,q,shelf,onwater);
-
-	tria->NodeConfiguration(tria_node_ids,tria_nodes,tria_node_offsets);
-	tria->MaticeConfiguration(matice,matice_offset);
-	tria->MatparConfiguration(matpar,matpar_offset);
-	tria->NumparConfiguration(numpar,numpar_offset);
-
-	return tria;
-
-}
-/*}}}*/
 /*FUNCTION UpdateFromInputs {{{1*/
 void  Penta::UpdateFromInputs(void* vinputs){
@@ -4043,8 +3985,16 @@
 	double  B_average;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matice* matice=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*If on water, skip: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matice=(Matice*)hmatice.delivers();
 
 	/*recover pointers: */
@@ -4052,14 +4002,14 @@
 
 	/*Update internal data if inputs holds new values: */
-	inputs->Recover("thickness",&h[0],1,dofs,6,(void**)nodes);
-	inputs->Recover("surface",&s[0],1,dofs,6,(void**)nodes);
-	inputs->Recover("bed",&b[0],1,dofs,6,(void**)nodes);
-	inputs->Recover("drag",&k[0],1,dofs,6,(void**)nodes);
-	inputs->Recover("melting",&melting[0],1,dofs,6,(void**)nodes);
-	inputs->Recover("accumulation_param",&accumulation[0],1,dofs,6,(void**)nodes);
+	inputs->Recover("thickness",&this->properties.h[0],1,dofs,6,(void**)nodes);
+	inputs->Recover("surface",&this->properties.s[0],1,dofs,6,(void**)nodes);
+	inputs->Recover("bed",&this->properties.b[0],1,dofs,6,(void**)nodes);
+	inputs->Recover("drag",&this->properties.k[0],1,dofs,6,(void**)nodes);
+	inputs->Recover("melting",&this->properties.melting[0],1,dofs,6,(void**)nodes);
+	inputs->Recover("accumulation_param",&this->properties.accumulation[0],1,dofs,6,(void**)nodes);
 
 	//Update material if necessary
 	if(inputs->Recover("temperature",&temperature_list[0],1,dofs,6,(void**)nodes)){
-		if(matice && !collapse){
+		if(matice && !this->properties.collapse){
 			//B_average=(Paterson(temperature_list[0])+Paterson(temperature_list[1])+Paterson(temperature_list[2])
 			//			+Paterson(temperature_list[3])+Paterson(temperature_list[4])+Paterson(temperature_list[5]))/6.0;
@@ -4071,5 +4021,5 @@
 
 	if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,6,(void**)nodes)){
-		if(matice && collapse){
+		if(matice && this->properties.collapse){
 			temperature_average=(temperature_list[0]+temperature_list[1]+temperature_list[2]+temperature_list[3]+temperature_list[4]+temperature_list[5])/6.0;
 			B_average=Paterson(temperature_average);
@@ -4096,13 +4046,13 @@
 
 	/*If on water, return 0: */
-	if(onwater)return 0;
+	if(this->properties.onwater)return 0;
 
 	/*Bail out if this element if:
 	 * -> Non collapsed and not on the surface
 	 * -> collapsed (2d model) and not on bed) */
-	if ((!collapse && !onsurface) || (collapse && !onbed)){
+	if ((!this->properties.collapse && !this->properties.onsurface) || (this->properties.collapse && !this->properties.onbed)){
 		return 0;
 	}
-	else if (collapse){
+	else if (this->properties.collapse){
 
 		/*This element should be collapsed into a tria element at its base. Create this tria element, 
Index: /issm/trunk/src/c/objects/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Penta.h	(revision 3382)
+++ /issm/trunk/src/c/objects/Penta.h	(revision 3383)
@@ -9,58 +9,38 @@
 #include "./Element.h"
 #include "./Matpar.h"
+#include "./Numpar.h"
 #include "./Matice.h"
 #include "./Node.h"
 #include "./Tria.h"
+#include "./Hook.h"
+#include "./ElementProperties.h"
 #include "./ParameterInputs.h"
+
+class Numpar;
+class Node;
+class Matice;
+class Matpar;
+class  ElementProperties;
 
 class Penta: public Element{
 
 	private: 
+
 		int id;
-		
-		/*nodes: */
-		int   node_ids[6]; //node ids
-		Node* nodes[6]; //node pointers
-		int   node_offsets[6]; //node offsets in nodes dataset
+		Hook hnodes;  //hook to 6 nodes
+		Hook hmatice; //hook to 1 matice
+		Hook hmatpar; //hook to 1 matpar
+		Hook hnumpar; //hook to 1 numpar
 
-		/*materials: */
-		int   mid;
-		Matice* matice; 
-		int   matice_offset;
-		
-		int mparid;
-		Matpar* matpar; 
-		int   matpar_offset;
+		ElementProperties properties;
 
-		int numparid;
-		Numpar* numpar; 
-		int   numpar_offset;
-	
-
-		double h[6];
-		double s[6];
-		double b[6];
-		double k[6];
-		double melting[6];
-		double accumulation[6];
-		int    friction_type;
-		double p;
-		double q;
-		int    shelf;
-		int    onbed;
-		int    onsurface;
-		bool   onwater;
-		int    collapse;
-		double geothermalflux[6];
-		int    thermal_steadystate;
-	
 	public:
 
+		/*FUNCTION constructors, destructors {{{1*/
 		Penta();
-		Penta( int id, int mid, int mparid, int numparid, int node_ids[6], double h[6], double s[6], double b[6], double k[6], int    friction_type, 
-				double p, double q, int    shelf, int    onbed, int    onsurface,  int    collapse, double melting[6], double accumulation[6], double geothermalflux[6], 
-				int    thermal_steadystate,bool onwater);
+		Penta(int penta_id,int* penta_node_ids, int penta_matice_id, int penta_matpar_id, int penta_numpar_id, ElementProperties* properties);
 		~Penta();
-
+		/*}}}*/
+		/*FUNCTION object management {{{1*/
 		void  Echo();
 		void  DeepEcho();
@@ -73,4 +53,6 @@
 		int   MyRank();
 		void  Configure(void* loads,void* nodes,void* materials,void* parameters);
+		/*}}}*/
+		/*FUNCTION element numerical routines {{{1*/
 		void  CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type);
 		void  CreateKMatrixDiagnosticHoriz( Mat Kgg, void* inputs, int analysis_type,int sub_analysis_type);
@@ -147,4 +129,5 @@
 		void  GetPhi(double* phi, double*  epsilon, double viscosity);
 		double MassFlux(double* segment,double* ug);
+		/*}}}*/
 
 
Index: /issm/trunk/src/c/objects/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Tria.cpp	(revision 3382)
+++ /issm/trunk/src/c/objects/Tria.cpp	(revision 3383)
@@ -11,4 +11,5 @@
 #include "stdio.h"
 #include "./Tria.h"
+#include "./Hook.h"
 #include <string.h>
 #include "../EnumDefinitions/EnumDefinitions.h"
@@ -25,6 +26,36 @@
 
 /*Object constructors and destructor*/
+/*FUNCTION Tria default constructor {{{1*/
+Tria::Tria(){
+	return;
+}
+/*}}}*/
 /*FUNCTION Tria constructor {{{1*/
-Tria::Tria(){
+Tria::Tria(int tria_id,int* tria_node_ids, int tria_matice_id, int tria_matpar_id, int tria_numpar_id, ElementProperties* triaproperties): 
+	hnodes(tria_node_ids,3),
+	hmatice(&tria_matice_id,1),
+	hmatpar(&tria_matpar_id,1),
+	hnumpar(&tria_numpar_id,1),
+	properties(triaproperties)
+{
+
+	/*all the initialization has been done by the initializer, just fill in the id: */
+	this->id=tria_id;
+
+	return;
+}
+/*}}}*/
+/*FUNCTION Tria other constructor {{{1*/
+Tria::Tria(int tria_id,Hook* tria_hnodes, Hook* tria_hmatice, Hook* tria_hmatpar, Hook* tria_hnumpar, ElementProperties* tria_properties):
+	hnodes(tria_hnodes),
+	hmatice(tria_hmatice),
+	hmatpar(tria_hmatpar),
+	hnumpar(tria_hnumpar),
+	properties(tria_properties)
+{
+
+	/*all the initialization has been done by the initializer, just fill in the id: */
+	this->id=tria_id;
+
 	return;
 }
@@ -35,44 +66,6 @@
 }
 /*}}}*/
-/*FUNCTION Tria creation {{{1*/
-Tria::Tria(int tria_id,int tria_mid,int tria_mparid,int tria_numparid,int tria_node_ids[3],double tria_h[3],double tria_s[3],double tria_b[3],double tria_k[3],double tria_melting[3],
-				double tria_accumulation[3],double tria_geothermalflux[3],int tria_friction_type,double tria_p,double tria_q,int tria_shelf, bool tria_onwater){
-	
-	int i;
-	
-	id=tria_id;
-	mid=tria_mid;
-	mparid=tria_mparid;
-	numparid=tria_numparid;
-	for(i=0;i<3;i++){
-		node_ids[i]=tria_node_ids[i];
-		node_offsets[i]=UNDEF;
-		nodes[i]=NULL;
-		h[i]=tria_h[i];
-		s[i]=tria_s[i];
-		b[i]=tria_b[i];
-		k[i]=tria_k[i];
-		melting[i]=tria_melting[i];
-		accumulation[i]=tria_accumulation[i];
-		geothermalflux[i]=tria_geothermalflux[i]; 
-	}
-	matice=NULL;
-	matice_offset=UNDEF;
-	matpar=NULL;
-	matpar_offset=UNDEF;
-	numpar=NULL;
-	numpar_offset=UNDEF;
-	friction_type=tria_friction_type;
-	p=tria_p;
-	q=tria_q;
-	shelf=tria_shelf;
-	onbed=1;
-	onwater=tria_onwater;
-	
-	return;
-}
-/*}}}*/
-
-/*Object marshall*/
+
+/*Object marshalling*/
 /*FUNCTION Marshall {{{1*/
 void  Tria::Marshall(char** pmarshalled_dataset){
@@ -92,29 +85,13 @@
 	/*marshall Tria data: */
 	memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(marshalled_dataset,&mid,sizeof(mid));marshalled_dataset+=sizeof(mid);
-	memcpy(marshalled_dataset,&mparid,sizeof(mparid));marshalled_dataset+=sizeof(mparid);
-	memcpy(marshalled_dataset,&node_ids,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids);
-	memcpy(marshalled_dataset,&nodes,sizeof(nodes));marshalled_dataset+=sizeof(nodes);
-	memcpy(marshalled_dataset,&node_offsets,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets);
-	memcpy(marshalled_dataset,&matice,sizeof(matice));marshalled_dataset+=sizeof(matice);
-	memcpy(marshalled_dataset,&matice_offset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset);
-	memcpy(marshalled_dataset,&matpar,sizeof(matpar));marshalled_dataset+=sizeof(matpar);
-	memcpy(marshalled_dataset,&matpar_offset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset);
-	memcpy(marshalled_dataset,&numparid,sizeof(numparid));marshalled_dataset+=sizeof(numparid);
-	memcpy(marshalled_dataset,&numpar,sizeof(numpar));marshalled_dataset+=sizeof(numpar);
-	memcpy(marshalled_dataset,&numpar_offset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset);
-	memcpy(marshalled_dataset,&h,sizeof(h));marshalled_dataset+=sizeof(h);
-	memcpy(marshalled_dataset,&s,sizeof(s));marshalled_dataset+=sizeof(s);
-	memcpy(marshalled_dataset,&b,sizeof(b));marshalled_dataset+=sizeof(b);
-	memcpy(marshalled_dataset,&k,sizeof(k));marshalled_dataset+=sizeof(k);
-	memcpy(marshalled_dataset,&melting,sizeof(melting));marshalled_dataset+=sizeof(melting);
-	memcpy(marshalled_dataset,&accumulation,sizeof(accumulation));marshalled_dataset+=sizeof(accumulation);
-	memcpy(marshalled_dataset,&geothermalflux,sizeof(geothermalflux));marshalled_dataset+=sizeof(geothermalflux);
-	memcpy(marshalled_dataset,&friction_type,sizeof(friction_type));marshalled_dataset+=sizeof(friction_type);
-	memcpy(marshalled_dataset,&onbed,sizeof(onbed));marshalled_dataset+=sizeof(onbed);
-	memcpy(marshalled_dataset,&onwater,sizeof(onwater));marshalled_dataset+=sizeof(onwater);
-	memcpy(marshalled_dataset,&p,sizeof(p));marshalled_dataset+=sizeof(p);
-	memcpy(marshalled_dataset,&q,sizeof(q));marshalled_dataset+=sizeof(q);
-	memcpy(marshalled_dataset,&shelf,sizeof(shelf));marshalled_dataset+=sizeof(shelf);
+
+	/*Marshall hooks: */
+	hnodes.Marshall(&marshalled_dataset);
+	hmatice.Marshall(&marshalled_dataset);
+	hmatpar.Marshall(&marshalled_dataset);
+	hnumpar.Marshall(&marshalled_dataset);
+
+	/*Marshall properties: */
+	properties.Marshall(&marshalled_dataset);
 
 	*pmarshalled_dataset=marshalled_dataset;
@@ -124,31 +101,12 @@
 /*FUNCTION MarshallSize {{{1*/
 int   Tria::MarshallSize(){
+	
 	return sizeof(id)
-	  +sizeof(mid)
-	  +sizeof(mparid)
-	  +sizeof(node_ids)
-	  +sizeof(nodes)
-	  +sizeof(node_offsets)
-	  +sizeof(matice)
-	  +sizeof(matice_offset)
-	  +sizeof(matpar)
-	  +sizeof(matpar_offset)
-	  +sizeof(numparid)
-	  +sizeof(numpar)
-	  +sizeof(numpar_offset)
-	  +sizeof(h)
-	  +sizeof(s)
-	  +sizeof(b)
-	  +sizeof(k)
-	  +sizeof(melting)
-	  +sizeof(accumulation)
-	  +sizeof(geothermalflux)
-	  +sizeof(friction_type)
-	  +sizeof(onbed)
-	  +sizeof(onwater)
-	  +sizeof(p)
-	  +sizeof(q)
-	  +sizeof(shelf)
-	  +sizeof(int); //sizeof(int) for enum type
+		+hnodes.MarshallSize()
+		+hmatice.MarshallSize()
+		+hmatpar.MarshallSize()
+		+hnumpar.MarshallSize()
+		+properties.MarshallSize()
+		+sizeof(int); //sizeof(int) for enum type
 }
 /*}}}*/
@@ -166,39 +124,74 @@
 
 	memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
-	memcpy(&mid,marshalled_dataset,sizeof(mid));marshalled_dataset+=sizeof(mid);
-	memcpy(&mparid,marshalled_dataset,sizeof(mparid));marshalled_dataset+=sizeof(mparid);
-	memcpy(&node_ids,marshalled_dataset,sizeof(node_ids));marshalled_dataset+=sizeof(node_ids);
-	memcpy(&nodes,marshalled_dataset,sizeof(nodes));marshalled_dataset+=sizeof(nodes);
-	memcpy(&node_offsets,marshalled_dataset,sizeof(node_offsets));marshalled_dataset+=sizeof(node_offsets);
-	memcpy(&matice,marshalled_dataset,sizeof(matice));marshalled_dataset+=sizeof(matice);
-	memcpy(&matice_offset,marshalled_dataset,sizeof(matice_offset));marshalled_dataset+=sizeof(matice_offset);
-	memcpy(&matpar,marshalled_dataset,sizeof(matpar));marshalled_dataset+=sizeof(matpar);
-	memcpy(&matpar_offset,marshalled_dataset,sizeof(matpar_offset));marshalled_dataset+=sizeof(matpar_offset);
-	memcpy(&numparid,marshalled_dataset,sizeof(numparid));marshalled_dataset+=sizeof(numparid);
-	memcpy(&numpar,marshalled_dataset,sizeof(numpar));marshalled_dataset+=sizeof(numpar);
-	memcpy(&numpar_offset,marshalled_dataset,sizeof(numpar_offset));marshalled_dataset+=sizeof(numpar_offset);
-	memcpy(&h,marshalled_dataset,sizeof(h));marshalled_dataset+=sizeof(h);
-	memcpy(&s,marshalled_dataset,sizeof(s));marshalled_dataset+=sizeof(s);
-	memcpy(&b,marshalled_dataset,sizeof(b));marshalled_dataset+=sizeof(b);
-	memcpy(&k,marshalled_dataset,sizeof(k));marshalled_dataset+=sizeof(k);
-	memcpy(&melting,marshalled_dataset,sizeof(melting));marshalled_dataset+=sizeof(melting);
-	memcpy(&accumulation,marshalled_dataset,sizeof(accumulation));marshalled_dataset+=sizeof(accumulation);
-	memcpy(&geothermalflux,marshalled_dataset,sizeof(geothermalflux));marshalled_dataset+=sizeof(geothermalflux);
-	memcpy(&friction_type,marshalled_dataset,sizeof(friction_type));marshalled_dataset+=sizeof(friction_type);
-	memcpy(&onbed,marshalled_dataset,sizeof(onbed));marshalled_dataset+=sizeof(onbed);
-	memcpy(&onwater,marshalled_dataset,sizeof(onwater));marshalled_dataset+=sizeof(onwater);
-	memcpy(&p,marshalled_dataset,sizeof(p));marshalled_dataset+=sizeof(p);
-	memcpy(&q,marshalled_dataset,sizeof(q));marshalled_dataset+=sizeof(q);
-	memcpy(&shelf,marshalled_dataset,sizeof(shelf));marshalled_dataset+=sizeof(shelf);
-
-	/*nodes and materials are not pointing to correct objects anymore:*/
-	for(i=0;i<3;i++)nodes[i]=NULL;
-	matice=NULL;
-	matpar=NULL;
-	numpar=NULL;
+
+	/*demarshall hooks: */
+	hnodes.Demarshall(&marshalled_dataset);
+	hmatice.Demarshall(&marshalled_dataset);
+	hmatpar.Demarshall(&marshalled_dataset);
+	hnumpar.Demarshall(&marshalled_dataset);
+
+	/*demarshall properties: */
+	properties.Demarshall(&marshalled_dataset);
 
 	/*return: */
 	*pmarshalled_dataset=marshalled_dataset;
 	return;
+}
+/*}}}*/
+
+/*Object processing: */
+/*FUNCTION Echo{{{1*/
+
+void Tria::Echo(void){
+
+	printf("Tria:\n");
+	printf("   id: %i\n",id);
+	hnodes.Echo();
+	hmatice.Echo();
+	hmatpar.Echo();
+	hnumpar.Echo();
+	properties.Echo();
+
+	return;
+}
+/*}}}*/
+/*FUNCTION DeepEcho{{{1*/
+
+void Tria::DeepEcho(void){
+
+	printf("Tria:\n");
+	printf("   id: %i\n",id);
+	hnodes.DeepEcho();
+	hmatice.DeepEcho();
+	hmatpar.DeepEcho();
+	hnumpar.DeepEcho();
+	properties.DeepEcho();
+
+	return;
+}
+/*}}}*/
+/*FUNCTION Configure {{{1*/
+void  Tria::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){
+
+	int i;
+
+	DataSet* loadsin=NULL;
+	DataSet* nodesin=NULL;
+	DataSet* materialsin=NULL;
+	DataSet* parametersin=NULL;
+
+	/*Recover pointers :*/
+	loadsin=(DataSet*)ploadsin;
+	nodesin=(DataSet*)pnodesin;
+	materialsin=(DataSet*)pmaterialsin;
+	parametersin=(DataSet*)pparametersin;
+
+	/*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);
+	hmatice.configure(materialsin);
+	hmatpar.configure(materialsin);
+	hnumpar.configure(parametersin);
+
 }
 /*}}}*/
@@ -213,7 +206,20 @@
 	double pressure[numgrids];
 	double rho_ice,g;
-
+	
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
+	
 	/*Get dof list on which we will plug the pressure values: */
 	GetDofList1(&doflist[0]);
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*pressure is lithostatic: */
@@ -221,37 +227,9 @@
 	g=matpar->GetG();
 	for(i=0;i<numgrids;i++){
-		pressure[i]=rho_ice*g*h[i];
+		pressure[i]=rho_ice*g*this->properties.h[i];
 	}
 
 	/*plug local pressure values into global pressure vector: */
 	VecSetValues(pg,numgrids,doflist,(const double*)pressure,INSERT_VALUES);
-
-}
-/*}}}*/
-/*FUNCTION Configure {{{1*/
-void  Tria::Configure(void* ploadsin,void* pnodesin,void* pmaterialsin,void* pparametersin){
-
-	int i;
-
-	DataSet* loadsin=NULL;
-	DataSet* nodesin=NULL;
-	DataSet* materialsin=NULL;
-	DataSet* parametersin=NULL;
-
-	/*Recover pointers :*/
-	loadsin=(DataSet*)ploadsin;
-	nodesin=(DataSet*)pnodesin;
-	materialsin=(DataSet*)pmaterialsin;
-	parametersin=(DataSet*)pparametersin;
-
-	/*Link this element with its nodes, ie find pointers to the nodes in the nodes dataset.: */
-	ResolvePointers((Object**)nodes,node_ids,node_offsets,3,nodesin);
-
-	/*Same for materials: */
-	ResolvePointers((Object**)&matice,&mid,&matice_offset,1,materialsin);
-	ResolvePointers((Object**)&matpar,&mparid,&matpar_offset,1,materialsin);
-
-	/*Same for numpar: */
-	ResolvePointers((Object**)&numpar,&numparid,&numpar_offset,1,parametersin);
 
 }
@@ -301,11 +279,23 @@
 	double Jdet;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*If on water, return 0: */
-	if(onwater)return 0;
+	if(this->properties.onwater)return 0;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -337,7 +327,7 @@
 		/*Add Tikhonov regularization term to misfit*/
 		if (strcmp(numpar->control_type,"drag")==0){
-			if (!shelf){
-
-				GetParameterDerivativeValue(&dk[0], &k[0],&xyz_list[0][0], gauss_l1l2l3);
+			if (!this->properties.shelf){
+
+				GetParameterDerivativeValue(&dk[0], &this->properties.k[0],&xyz_list[0][0], gauss_l1l2l3);
 				Jelem+=numpar->cm_noisedmp*1/2*(pow(dk[0],2)+pow(dk[1],2))*Jdet*gauss_weight;
 
@@ -464,8 +454,20 @@
 	int     found=0;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -666,8 +668,20 @@
 	int     found=0;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -685,5 +699,5 @@
 
 	/*Modify z so that it reflects the surface*/
-	for(i=0;i<numgrids;i++) xyz_list[i][2]=s[i];
+	for(i=0;i<numgrids;i++) xyz_list[i][2]=this->properties.s[i];
 
 	/*Get normal vector to the surface*/
@@ -875,11 +889,23 @@
 	int     dofs[2]={0,1};
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*First, if we are on water, return empty matrix: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -935,5 +961,5 @@
 
 		/*Compute thickness at gaussian point: */
-		GetParameterValue(&thickness, &h[0],gauss_l1l2l3);
+		GetParameterValue(&thickness, &this->properties.h[0],gauss_l1l2l3);
 
 		/*Get strain rate from velocity: */
@@ -1012,5 +1038,5 @@
 
 	/*Do not forget to include friction: */
-	if(!shelf){
+	if(!this->properties.shelf){
 		CreateKMatrixDiagnosticHorizFriction(Kgg,inputs,analysis_type,sub_analysis_type);
 	}
@@ -1090,8 +1116,20 @@
 	double MOUNTAINKEXPONENT=10;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 	
 	/* Get node coordinates and dof list: */
@@ -1102,10 +1140,10 @@
 	for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke_gg[i][j]=0.0;
 
-	if (shelf){
+	if (this->properties.shelf){
 		/*no friction, do nothing*/
 		return;
 	}
 
-	if (friction_type!=2)ISSMERROR(" non-viscous friction not supported yet!");
+	if (this->properties.friction_type!=2)ISSMERROR(" non-viscous friction not supported yet!");
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -1122,10 +1160,10 @@
 	friction->rho_ice=matpar->GetRhoIce();
 	friction->rho_water=matpar->GetRhoWater();
-	friction->K=&k[0];
-	friction->bed=&b[0];
-	friction->thickness=&h[0];
+	friction->K=&this->properties.k[0];
+	friction->bed=&this->properties.b[0];
+	friction->thickness=&this->properties.h[0];
 	friction->velocities=&vxvy_list[0][0];
-	friction->p=p;
-	friction->q=q;
+	friction->p=this->properties.p;
+	friction->q=this->properties.q;
 
 	/*Compute alpha2_list: */
@@ -1164,5 +1202,5 @@
 		// If we have a slope > 6% for this element,  it means  we are on a mountain. In this particular case, 
 		//velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */
-		GetParameterDerivativeValue(&slope[0], &s[0],&xyz_list[0][0], gauss_l1l2l3);
+		GetParameterDerivativeValue(&slope[0], &this->properties.s[0],&xyz_list[0][0], gauss_l1l2l3);
 		slope_magnitude=sqrt(pow(slope[0],2)+pow(slope[1],2));
 
@@ -1250,8 +1288,20 @@
 	double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix evaluated at the gaussian point.
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -1368,4 +1418,16 @@
 	double     tLD[3];
 	double     Ke_gaussian[numdof][numdof]={0.0};
+
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*Recover constants of ice */
@@ -1469,8 +1531,20 @@
 	int     found;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -1678,8 +1752,20 @@
 	int     found;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -1808,5 +1894,17 @@
 	
 	double Jdet;
-	
+
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
+
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
@@ -1894,6 +1992,18 @@
 	ParameterInputs* inputs=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, dt: */
@@ -2037,8 +2147,20 @@
 	int     found=0;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -2126,8 +2248,26 @@
 	int     found=0;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -2224,8 +2364,20 @@
 	int     dofs2[1]={1};
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* recover input parameters: */
@@ -2254,5 +2406,5 @@
 
 		/*Get melting at gaussian point: */
-		GetParameterValue(&meltingvalue, &melting[0],gauss_l1l2l3);
+		GetParameterValue(&meltingvalue, &this->properties.melting[0],gauss_l1l2l3);
 
 		/*Get velocity at gaussian point: */
@@ -2261,5 +2413,5 @@
 
 		/*Get bed slope: */
-		GetParameterDerivativeValue(&slope[0], &b[0],&xyz_list[0][0], gauss_l1l2l3);
+		GetParameterDerivativeValue(&slope[0], &this->properties.b[0],&xyz_list[0][0], gauss_l1l2l3);
 		dbdx=slope[0];
 		dbdy=slope[1];
@@ -2333,11 +2485,23 @@
 	double  thickness;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*First, if we are on water, return empty vector: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -2384,12 +2548,12 @@
 
 		/*Compute thickness at gaussian point: */
-		GetParameterValue(&thickness, &h[0],gauss_l1l2l3);
+		GetParameterValue(&thickness, &this->properties.h[0],gauss_l1l2l3);
 	
-		GetParameterDerivativeValue(&slope[0], &s[0],&xyz_list[0][0], gauss_l1l2l3);
+		GetParameterDerivativeValue(&slope[0], &this->properties.s[0],&xyz_list[0][0], gauss_l1l2l3);
 		
 		/*In case we have plastic basal drag, compute plastic stress at gaussian point from k1, k2 and k3 fields in the 
 		 * element itself: */
-		if(friction_type==1){
-			GetParameterValue(&plastic_stress, &k[0],gauss_l1l2l3);
+		if(this->properties.friction_type==1){
+			GetParameterValue(&plastic_stress, &this->properties.k[0],gauss_l1l2l3);
 		}
 
@@ -2417,5 +2581,5 @@
 
 		/*Build pe_g_gaussian vector: */
-		if(friction_type==1){
+		if(this->properties.friction_type==1){
 			for (i=0;i<numgrids;i++){
 				for (j=0;j<NDOF2;j++){
@@ -2502,8 +2666,20 @@
 	int     found=0;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -2598,8 +2774,20 @@
 	int     found=0;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*recover extra inputs from users, at current convergence iteration: */
@@ -2690,4 +2878,16 @@
 	double  slope[2];
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
+
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
@@ -2698,8 +2898,8 @@
 
 	if ( (sub_analysis_type==SurfaceXAnalysisEnum()) || (sub_analysis_type==SurfaceYAnalysisEnum())){
-		for(i=0;i<numdof;i++) param[i]=s[i];
+		for(i=0;i<numdof;i++) param[i]=this->properties.s[i];
 	}
 	if ( (sub_analysis_type==BedXAnalysisEnum()) || (sub_analysis_type==BedYAnalysisEnum())){
-		for(i=0;i<numdof;i++) param[i]=b[i];
+		for(i=0;i<numdof;i++) param[i]=this->properties.b[i];
 	}
 
@@ -2791,8 +2991,20 @@
 	double  scalar_ocean;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+	
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 	
 	/* Get node coordinates and dof list: */
@@ -2906,6 +3118,18 @@
 	ParameterInputs* inputs=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 	
 	/* Get node coordinates and dof list: */
@@ -2934,5 +3158,5 @@
 	
 	/*Initialize all fields: */
-	if (friction_type!=2)ISSMERROR(" non-viscous friction not supported yet!");
+	if (this->properties.friction_type!=2)ISSMERROR(" non-viscous friction not supported yet!");
 	
 	friction->element_type=(char*)xmalloc((strlen("3d")+1)*sizeof(char));
@@ -2942,10 +3166,10 @@
 	friction->rho_ice=matpar->GetRhoIce();
 	friction->rho_water=matpar->GetRhoWater();
-	friction->K=&k[0];
-	friction->bed=&b[0];
-	friction->thickness=&h[0];
+	friction->K=&this->properties.k[0];
+	friction->bed=&this->properties.b[0];
+	friction->thickness=&this->properties.h[0];
 	friction->velocities=&vxvyvz_list[0][0];
-	friction->p=p;
-	friction->q=q;
+	friction->p=this->properties.p;
+	friction->q=this->properties.q;
 
 	/*Compute alpha2_list: */
@@ -2977,5 +3201,5 @@
 
 		/*Get geothermal flux and basal friction */
-		GetParameterValue(&geothermalflux_value,&geothermalflux[0],gauss_coord);
+		GetParameterValue(&geothermalflux_value,&this->properties.geothermalflux[0],gauss_coord);
 		GetParameterValue(&basalfriction,&basalfriction_list[0],gauss_coord);
 
@@ -3000,39 +3224,4 @@
 	xfree((void**)&gauss_weights);
 
-}
-/*}}}*/
-/*FUNCTION DeepEcho{{{1*/
-
-void Tria::DeepEcho(void){
-
-	printf("Tria:\n");
-	printf("   id: %i\n",id);
-	printf("   mid: %i\n",mid);
-	printf("   mparid: %i\n",mparid);
-	printf("   node_ids=[%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2]);
-	printf("   node_offsets=[%i,%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2]);
-	printf("   matice_offset=%i\n",matice_offset);
-	printf("   matpar_offset=%i\n",matpar_offset);
-	printf("   h=[%g,%g,%g]\n",h[0],h[1],h[2]);
-	printf("   s=[%g,%g,%g]\n",s[0],s[1],s[2]);
-	printf("   b=[%g,%g,%g]\n",b[0],b[1],b[2]);
-	printf("   k=[%g,%g,%g]\n",k[0],k[1],k[2]);
-	printf("   melting=[%g,%g,%g]\n",melting[0],melting[1],melting[2]);
-	printf("   accumulation=[%g,%g,%g]\n",accumulation[0],accumulation[1],accumulation[2]);
-	printf("   geothermalflux=[%g,%g,%g]\n",geothermalflux[0],geothermalflux[1],geothermalflux[2]);
-	printf("   friction_type: %i\n",friction_type);
-	printf("   p: %g\n",p);
-	printf("   q: %g\n",q);
-	printf("   shelf: %i\n",shelf);
-	printf("   onbed: %i\n",onbed);
-	printf("   onwater: %i\n",onwater);
-	printf("   nodes: \n");
-	if(nodes[0])nodes[0]->Echo();
-	if(nodes[1])nodes[1]->Echo();
-	if(nodes[2])nodes[2]->Echo();
-	if(matice)matice->Echo();
-	if(matpar)matpar->Echo();
-
-	return;
 }
 /*}}}*/
@@ -3093,8 +3282,20 @@
 	double fit=-1;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -3302,39 +3503,4 @@
 }
 /*}}}*/
-/*FUNCTION Echo {{{1*/
-
-void Tria::Echo(void){
-
-	printf("Tria:\n");
-	printf("   id: %i\n",id);
-	printf("   mid: %i\n",mid);
-	printf("   mparid: %i\n",mparid);
-	printf("   node_ids=[%i,%i,%i]\n",node_ids[0],node_ids[1],node_ids[2]);
-	printf("   node_offsets=[%i,%i,%i]\n",node_offsets[0],node_offsets[1],node_offsets[2]);
-	printf("   matice_offset=%i\n",matice_offset);
-	printf("   matpar_offset=%i\n",matpar_offset);
-	printf("   h=[%g,%g,%g]\n",h[0],h[1],h[2]);
-	printf("   s=[%g,%g,%g]\n",s[0],s[1],s[2]);
-	printf("   b=[%g,%g,%g]\n",b[0],b[1],b[2]);
-	printf("   k=[%g,%g,%g]\n",k[0],k[1],k[2]);
-	printf("   melting=[%g,%g,%g]\n",melting[0],melting[1],melting[2]);
-	printf("   accumulation=[%g,%g,%g]\n",accumulation[0],accumulation[1],accumulation[2]);
-	printf("   geothermalflux=[%g,%g,%g]\n",geothermalflux[0],geothermalflux[1],geothermalflux[2]);
-	printf("   friction_type: %i\n",friction_type);
-	printf("   p: %g\n",p);
-	printf("   q: %g\n",q);
-	printf("   shelf: %i\n",shelf);
-	printf("   onbed: %i\n",onbed);
-	printf("   onwater: %i\n",onwater);
-	printf("   nodes: \n");
-	if(nodes[0])nodes[0]->Echo();
-	if(nodes[1])nodes[1]->Echo();
-	if(nodes[2])nodes[2]->Echo();
-	if(matice)matice->Echo();
-	if(matpar)matpar->Echo();
-
-	return;
-}
-/*}}}*/
 /*FUNCTION Enum {{{1*/
 int Tria::Enum(void){
@@ -3351,4 +3517,10 @@
 	double xyz_list[numgrids][3];
 	double x1,y1,x2,y2,x3,y3;
+
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
 
 	/*Get xyz list: */
@@ -3368,4 +3540,10 @@
 	double xyz_list[numgrids][3];
 	double x1,y1,x2,y2,x3,y3;
+
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
 
 	/*Get area: */
@@ -3476,5 +3654,5 @@
 
 	int i;
-	for(i=0;i<3;i++)bed_list[i]=b[i];
+	for(i=0;i<3;i++)bed_list[i]=this->properties.b[i];
 
 }
@@ -3555,4 +3733,10 @@
 	int doflist_per_node[MAXDOFSPERNODE];
 	int numberofdofspernode;
+
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
 	
 	for(i=0;i<3;i++){
@@ -3571,4 +3755,10 @@
 void  Tria::GetDofList1(int* doflist){
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	
 	int i;
 	for(i=0;i<3;i++){
@@ -3723,4 +3913,11 @@
 /*FUNCTION GetMatPar {{{1*/
 void* Tria::GetMatPar(){
+
+	/*dynamic objects pointed to by hooks: */
+	Matpar* matpar=NULL;
+
+	/*recover objects from hooks: */
+	matpar=(Matpar*)hmatpar.delivers();
+
 	return matpar;
 }
@@ -3806,6 +4003,15 @@
 void  Tria::GetNodes(void** vpnodes){
 	int i;
-	Node** pnodes=(Node**)vpnodes;
-
+	Node** pnodes=NULL;
+
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	
+	/*recover nodes: */
+	pnodes=(Node**)vpnodes;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	
 	for(i=0;i<3;i++){
 		pnodes[i]=nodes[i];
@@ -3815,5 +4021,5 @@
 /*FUNCTION GetOnBed {{{1*/
 int Tria::GetOnBed(){
-	return onbed;
+	return this->properties.onbed;
 }
 /*}}}*/
@@ -3863,5 +4069,5 @@
 /*FUNCTION GetShelf {{{1*/
 int   Tria::GetShelf(){
-	return shelf;
+	return this->properties.shelf;
 }
 /*}}}*/
@@ -3889,5 +4095,5 @@
 
 	int i;
-	for(i=0;i<3;i++)thickness_list[i]=h[i];
+	for(i=0;i<3;i++)thickness_list[i]=this->properties.h[i];
 }
 /*}}}*/
@@ -3896,5 +4102,5 @@
 
 	/*If on water, grad = 0: */
-	if(onwater)return;
+	if(this->properties.onwater)return;
 
 	if (strcmp(control_type,"drag")==0){
@@ -3968,8 +4174,20 @@
 	double  B_gauss;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -3981,5 +4199,5 @@
 
 	/* recover input parameters: */
-	inputs->Recover("thickness",&h[0],1,dofs,numgrids,(void**)nodes);
+	inputs->Recover("thickness",&this->properties.h[0],1,dofs,numgrids,(void**)nodes);
 	if(!inputs->Recover("velocity",&vxvy_list[0][0],2,dofs2,numgrids,(void**)nodes)){
 		ISSMERROR("missing velocity input parameter");
@@ -4017,5 +4235,5 @@
 
 		/*Get thickness: */
-		GetParameterValue(&thickness, &h[0],gauss_l1l2l3);
+		GetParameterValue(&thickness, &this->properties.h[0],gauss_l1l2l3);
 
 		/*Get strain rate, if velocity has been supplied: */
@@ -4140,4 +4358,10 @@
 	double epsilon[3]; /* epsilon=[exx,eyy,exy];*/
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
@@ -4145,6 +4369,12 @@
 	inputs=(ParameterInputs*)vinputs;
 
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
+
 	/*Get out if shelf*/
-	if(shelf) return;
+	if(this->properties.shelf) return;
 
 	/* Get node coordinates and dof list: */
@@ -4156,7 +4386,7 @@
 
 	/* recover input parameters: */
-	inputs->Recover("drag",&k[0],1,dofs1,numgrids,(void**)nodes);
-	inputs->Recover("bed",&b[0],1,dofs1,numgrids,(void**)nodes);
-	inputs->Recover("thickness",&h[0],1,dofs1,numgrids,(void**)nodes);
+	inputs->Recover("drag",&this->properties.k[0],1,dofs1,numgrids,(void**)nodes);
+	inputs->Recover("bed",&this->properties.b[0],1,dofs1,numgrids,(void**)nodes);
+	inputs->Recover("thickness",&this->properties.h[0],1,dofs1,numgrids,(void**)nodes);
 	if(!inputs->Recover("velocity",&vxvy_list[0][0],2,dofs2,numgrids,(void**)nodes)){
 		ISSMERROR("missing velocity input parameter");
@@ -4195,5 +4425,5 @@
 
 		/*Build alpha_complement_list: */
-		if (!shelf && (friction_type==2)){
+		if (!this->properties.shelf && (this->properties.friction_type==2)){
 		
 			/*Allocate friction object: */
@@ -4207,10 +4437,10 @@
 			friction->rho_ice=matpar->GetRhoIce();
 			friction->rho_water=matpar->GetRhoWater();
-			friction->K=&k[0];
-			friction->bed=&b[0];
-			friction->thickness=&h[0];
+			friction->K=&this->properties.k[0];
+			friction->bed=&this->properties.b[0];
+			friction->thickness=&this->properties.h[0];
 			friction->velocities=&vxvy_list[0][0];
-			friction->p=p;
-			friction->q=q;
+			friction->p=this->properties.p;
+			friction->q=this->properties.q;
 
 			if(friction->p!=1) ISSMERROR("non-linear friction not supported yet in control methods!");
@@ -4230,5 +4460,5 @@
 		/*Recover alpha_complement and k: */
 		GetParameterValue(&alpha_complement, &alpha_complement_list[0],gauss_l1l2l3);
-		GetParameterValue(&drag, &k[0],gauss_l1l2l3);
+		GetParameterValue(&drag, &this->properties.k[0],gauss_l1l2l3);
 		#ifdef _ISSM_DEBUG_ 
 			printf("Drag complement: %20.20lf Drag: %20.20lf\n",alpha_complement,drag);
@@ -4262,5 +4492,5 @@
 
 		/*Get k derivative: dk/dx */
-		GetParameterDerivativeValue(&dk[0], &k[0],&xyz_list[0][0], gauss_l1l2l3);
+		GetParameterDerivativeValue(&dk[0], &this->properties.k[0],&xyz_list[0][0], gauss_l1l2l3);
 
 		/*Build gradje_g_gaussian vector (actually -dJ/ddrag): */
@@ -4362,9 +4592,21 @@
 	ParameterInputs* inputs=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	/*Get out if shelf*/
-	if(shelf) return;
+	if(this->properties.shelf) return;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -4376,7 +4618,7 @@
 
 	/* recover input parameters: */
-	inputs->Recover("drag",&k[0],1,dofs1,numgrids,(void**)nodes);
-	inputs->Recover("bed",&b[0],1,dofs1,numgrids,(void**)nodes);
-	inputs->Recover("thickness",&h[0],1,dofs1,numgrids,(void**)nodes);
+	inputs->Recover("drag",&this->properties.k[0],1,dofs1,numgrids,(void**)nodes);
+	inputs->Recover("bed",&this->properties.b[0],1,dofs1,numgrids,(void**)nodes);
+	inputs->Recover("thickness",&this->properties.h[0],1,dofs1,numgrids,(void**)nodes);
 	if(!inputs->Recover("velocity",&vxvyvz_list[0][0],3,dofs3,numgrids,(void**)nodes)){
 		ISSMERROR("missing velocity input parameter");
@@ -4417,5 +4659,5 @@
 
 		/*Build alpha_complement_list: */
-		if (!shelf && (friction_type==2)){
+		if (!this->properties.shelf && (this->properties.friction_type==2)){
 
 			/*Allocate friction object: */
@@ -4429,10 +4671,10 @@
 			friction->rho_ice=matpar->GetRhoIce();
 			friction->rho_water=matpar->GetRhoWater();
-			friction->K=&k[0];
-			friction->bed=&b[0];
-			friction->thickness=&h[0];
+			friction->K=&this->properties.k[0];
+			friction->bed=&this->properties.b[0];
+			friction->thickness=&this->properties.h[0];
 			friction->velocities=&vxvyvz_list[0][0];
-			friction->p=p;
-			friction->q=q;
+			friction->p=this->properties.p;
+			friction->q=this->properties.q;
 
 			if(friction->p!=1) ISSMERROR("non-linear friction not supported yet in control methods!");
@@ -4452,5 +4694,5 @@
 		/*Recover alpha_complement and k: */
 		GetParameterValue(&alpha_complement, &alpha_complement_list[0],gauss_l1l2l3);
-		GetParameterValue(&drag, &k[0],gauss_l1l2l3);
+		GetParameterValue(&drag, &this->properties.k[0],gauss_l1l2l3);
 #ifdef _ISSM_DEBUG_ 
 		printf("Drag complement: %20.20lf Drag: %20.20lf\n",alpha_complement,drag);
@@ -4493,5 +4735,5 @@
 
 		/*Get k derivative: dk/dx */
-		GetParameterDerivativeValue(&dk[0], &k[0],&xyz_list[0][0], gauss_l1l2l3);
+		GetParameterDerivativeValue(&dk[0], &this->properties.k[0],&xyz_list[0][0], gauss_l1l2l3);
 
 		/*Build gradje_g_gaussian vector (actually -dJ/ddrag): */
@@ -4555,6 +4797,14 @@
 	double rho_ice;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+
 	/*Get material parameters :*/
-	rho_ice=this->matpar->GetRhoIce();
+	rho_ice=matpar->GetRhoIce();
 
 	/*First off, check that this segment belongs to this element: */
@@ -4588,6 +4838,6 @@
 
 	/*get thickness and velocity at two segment extremities: */
-	GetParameterValue(&h1, &h[0],gauss_1);
-	GetParameterValue(&h2, &h[0],gauss_2);
+	GetParameterValue(&h1, &this->properties.h[0],gauss_1);
+	GetParameterValue(&h2, &this->properties.h[0],gauss_2);
 	GetParameterValue(&vx1, &vx_list[0],gauss_1);
 	GetParameterValue(&vy1, &vy_list[0],gauss_1);
@@ -4605,6 +4855,16 @@
 /*FUNCTION MaticeConfiguration {{{1*/
 void  Tria::MaticeConfiguration(Matice* tria_matice,int tria_matice_offset){
-	   matice=tria_matice;
-		   matice_offset=tria_matice_offset;
+
+	/*dynamic objects pointed to by hooks: */
+	Matice* matice=NULL;
+
+	/*recover objects from hooks: */
+	matice=(Matice*)hmatice.delivers();
+	
+	ISSMERROR("not supported yet!");
+
+	/*matice=tria_matice;
+	matice_offset=tria_matice_offset;*/
+
 }
 /*}}}*/
@@ -4612,6 +4872,14 @@
 void  Tria::MatparConfiguration(Matpar* tria_matpar,int tria_matpar_offset){
 
-	   matpar=tria_matpar;
-		   matpar_offset=tria_matpar_offset;
+	/*dynamic objects pointed to by hooks: */
+	Matpar* matpar=NULL;
+
+	/*recover objects from hooks: */
+	matpar=(Matpar*)hmatpar.delivers();
+
+	ISSMERROR("not supported yet!");
+
+	/*matpar=tria_matpar;
+	matpar_offset=tria_matpar_offset;*/
 
 }
@@ -4667,9 +4935,21 @@
 	ParameterInputs* inputs=NULL;
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	/*If on water, return 0: */
-	if(onwater)return 0;
+	if(this->properties.onwater)return 0;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/* Get node coordinates and dof list: */
@@ -4824,10 +5104,18 @@
 void  Tria::NodeConfiguration(int* tria_node_ids,Node* tria_nodes[3],int* tria_node_offsets){
 
-	int i;
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+
+	ISSMERROR("not supported yet!");
+
+	/*int i;
 	for(i=0;i<3;i++){
 		node_ids[i]=tria_node_ids[i];
 		nodes[i]=tria_nodes[i];
 		node_offsets[i]=tria_node_offsets[i];
-	}
+	}*/
 
 }
@@ -4836,6 +5124,14 @@
 void  Tria::NumparConfiguration(Numpar* tria_numpar,int tria_numpar_offset){
 
-	numpar=tria_numpar;
-	numpar_offset=tria_numpar_offset;
+	/*dynamic objects pointed to by hooks: */
+	Numpar* numpar=NULL;
+
+	/*recover objects from hooks: */
+	numpar=(Numpar*)hnumpar.delivers();
+
+	ISSMERROR("not supported yet!");
+
+	/*numpar=tria_numpar;
+	numpar_offset=tria_numpar_offset;*/
 
 }
@@ -4883,6 +5179,12 @@
 	double normal[3];
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+
 	/*If on water, return 0: */
-	if(onwater)return 0;
+	if(this->properties.onwater)return 0;
 
 	/* Get node coordinates and dof list: */
@@ -4915,13 +5217,25 @@
 	double  new_h[3];
 
+	/*dynamic objects pointed to by hooks: */
+	Node**  nodes=NULL;
+	Matpar* matpar=NULL;
+	Matice* matice=NULL;
+	Numpar* numpar=NULL;
+
 	ParameterInputs* inputs=NULL;
 
 	/*recover pointers: */
 	inputs=(ParameterInputs*)vinputs;
+
+	/*recover objects from hooks: */
+	nodes=(Node**)hnodes.deliverp();
+	matpar=(Matpar*)hmatpar.delivers();
+	matice=(Matice*)hmatice.delivers();
+	numpar=(Numpar*)hnumpar.delivers();
 
 	/*Update internal data if inputs holds new values: */
 	//if (id==1) printf("WARNING if QMU: no hydrostatic equilibrium is applied here (conflict with prognostic, which does not have matpar)\n");
 	//For now
-	inputs->Recover("thickness",&h[0],1,dofs,3,(void**)nodes);
+	inputs->Recover("thickness",&this->properties.h[0],1,dofs,3,(void**)nodes);
 	//Later
 	/*
@@ -4931,5 +5245,5 @@
 	//Go through grids:
 	for (i=0;i<3;i++){
-	if(this->nodes[i]->IsOnShelf()){
+	if(nodes[i]->IsOnShelf()){
 	this->b[i]=this->b[i]-di*(new_h[i]-h[i]); //hydrostatic equilibrium;
 	}
@@ -4939,10 +5253,10 @@
 	}
 	*/
-	inputs->Recover("surface",&s[0],1,dofs,3,(void**)nodes);
-	inputs->Recover("bed",&b[0],1,dofs,3,(void**)nodes);
-	inputs->Recover("drag",&k[0],1,dofs,3,(void**)nodes);
-	inputs->Recover("melting",&melting[0],1,dofs,3,(void**)nodes);
-	inputs->Recover("accumulation",&accumulation[0],1,dofs,3,(void**)nodes);
-	inputs->Recover("geothermalflux",&geothermalflux[0],1,dofs,3,(void**)nodes);
+	inputs->Recover("surface",&this->properties.s[0],1,dofs,3,(void**)nodes);
+	inputs->Recover("bed",&this->properties.b[0],1,dofs,3,(void**)nodes);
+	inputs->Recover("drag",&this->properties.k[0],1,dofs,3,(void**)nodes);
+	inputs->Recover("melting",&this->properties.melting[0],1,dofs,3,(void**)nodes);
+	inputs->Recover("accumulation",&this->properties.accumulation[0],1,dofs,3,(void**)nodes);
+	inputs->Recover("geothermalflux",&this->properties.geothermalflux[0],1,dofs,3,(void**)nodes);
 	
 	//Update material if necessary
Index: /issm/trunk/src/c/objects/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Tria.h	(revision 3382)
+++ /issm/trunk/src/c/objects/Tria.h	(revision 3383)
@@ -8,4 +8,6 @@
 
 #include "./Element.h"
+#include "../DataSet/DataSet.h"
+#include "./Object.h"
 #include "./Node.h"
 #include "./Matice.h"
@@ -13,4 +15,11 @@
 #include "./Numpar.h"
 #include "./ParameterInputs.h"
+#include "./ElementProperties.h"
+#include "./Hook.h"
+
+class Object;
+class Hook;
+class ElementProperties;
+class DataSet;
 
 class Tria: public Element{
@@ -18,45 +27,22 @@
 	private: 
 
-		/*ids:*/
-		int id;
+		int  id;
 
-		/*nodes: */
-		int   node_ids[3]; //node ids
-		Node* nodes[3]; //node pointers
-		int   node_offsets[3]; //node offsets in nodes dataset
+		Hook hnodes;  //hook to 3 nodes
+		Hook hmatice; //hook to 1 matice
+		Hook hmatpar; //hook to 1 matpar
+		Hook hnumpar; //hook to 1 numpar
 
-		/*materials: */
-		int   mid;
-		Matice* matice; 
-		int   matice_offset;
-		
-		int mparid;
-		Matpar* matpar; 
-		int   matpar_offset;
-
-		int numparid;
-		Numpar* numpar; 
-		int   numpar_offset;
+		ElementProperties properties;
 	
-		double h[3];
-		double s[3];
-		double b[3];
-		double k[3];
-		double melting[3];
-		double accumulation[3];
-		double geothermalflux[3];
-		int    friction_type;
-		double p;
-		double q;
-		int    shelf;
-		int    onbed;
-		bool   onwater;
-
 	public:
 
+		/*FUNCTION constructors, destructors {{{1*/
 		Tria();
-		Tria(int id,int mid,int mparid,int numparid,int node_ids[3],double h[3],double s[3],double b[3],double k[3],double melting[3],double accumulation[3],double geothermalflux[3],int friction_type,double p,double q,int shelf,bool onwater);
+		Tria(int tria_id,int* tria_node_ids, int tria_matice_id, int tria_matpar_id, int tria_numpar_id, ElementProperties* tria_properties);
+		Tria(int tria_id,Hook* tria_hnodes, Hook* tria_hmatice, Hook* tria_hmatpar, Hook* tria_hnumpar, ElementProperties* tria_properties);
 		~Tria();
-
+		/*}}}*/
+		/*FUNCTION object management {{{1*/
 		void  Echo();
 		void  DeepEcho();
@@ -68,4 +54,6 @@
 		int   GetId(); 
 		int   MyRank();
+		/*}}}*/
+		/*FUNCTION element numerical routines {{{1*/
 		void  Configure(void* loads,void* nodes,void* materials,void* parameters);
 		void  CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type);
@@ -134,4 +122,5 @@
 		double GetArea(void);
 		double GetAreaCoordinate(double x, double y, int which_one);
+		/*}}}*/
 
 };
Index: /issm/trunk/src/m/classes/public/plot/applyoptions.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/applyoptions.m	(revision 3382)
+++ /issm/trunk/src/m/classes/public/plot/applyoptions.m	(revision 3383)
@@ -90,13 +90,5 @@
 %Caxis
 if exist(options,'caxis'),
-	if exist(options,'log'),
-		logvalue=getfieldvalue(options,'log');
-		if any(getfieldvalue(options,'caxis')<=0),
-			error('applyoptions error message: negative log values when trying to apply caxis option');
-		end
-		caxis(log(getfieldvalue(options,'caxis'))/log(logvalue));
-	else
-		caxis(getfieldvalue(options,'caxis'));
-	end
+	caxis(getfieldvalue(options,'caxis'));
 end
 
Index: /issm/trunk/src/m/enum/ElementPropertiesEnum.m
===================================================================
--- /issm/trunk/src/m/enum/ElementPropertiesEnum.m	(revision 3383)
+++ /issm/trunk/src/m/enum/ElementPropertiesEnum.m	(revision 3383)
@@ -0,0 +1,9 @@
+function macro=ElementPropertiesEnum()
+%ELEMENTPROPERTIESENUM - Enum of ElementProperties
+%
+%   file generated by src/c/EnumDefinitions/SynchronizeMatlabEnum
+%
+%   Usage:
+%      macro=ElementPropertiesEnum()
+
+macro=412;
Index: /issm/trunk/src/m/enum/HookEnum.m
===================================================================
--- /issm/trunk/src/m/enum/HookEnum.m	(revision 3383)
+++ /issm/trunk/src/m/enum/HookEnum.m	(revision 3383)
@@ -0,0 +1,9 @@
+function macro=HookEnum()
+%HOOKENUM - Enum of Hook
+%
+%   file generated by src/c/EnumDefinitions/SynchronizeMatlabEnum
+%
+%   Usage:
+%      macro=HookEnum()
+
+macro=409;
Index: /issm/trunk/src/m/enum/PentaEnum.m
===================================================================
--- /issm/trunk/src/m/enum/PentaEnum.m	(revision 3382)
+++ /issm/trunk/src/m/enum/PentaEnum.m	(revision 3383)
@@ -7,3 +7,3 @@
 %      macro=PentaEnum()
 
-macro=412;
+macro=413;
Index: /issm/trunk/todo
===================================================================
--- /issm/trunk/todo	(revision 3382)
+++ /issm/trunk/todo	(revision 3383)
@@ -82,3 +82,5 @@
 
 Get Matlab 7.8: version 4.2.3
-Use gprof to figure out where we are losing out time.
+Use gprof to figure out where we are losing out time. 
+
+Get rid of ResolvePointers
