diff --git a/Common/Makefile b/Common/Makefile
index 1189dc102fda82715e9f472fa9133d28961c77af..9d64847843a66892333e1d03c90881866ead144d 100644
--- a/Common/Makefile
+++ b/Common/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.149 2008-01-19 22:05:59 geuzaine Exp $
+# $Id: Makefile,v 1.150 2008-01-19 23:04:11 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -105,9 +105,8 @@ Visibility.o: Visibility.cpp Visibility.h GmshDefines.h ../Geo/GVertex.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h \
   ../Geo/GRegion.h ../Geo/SBoundingBox3d.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Parser/Parser.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Parser/Parser.h ../DataStr/List.h \
   ../DataStr/Tree.h ../DataStr/avl.h
 Trackball.o: Trackball.cpp Trackball.h
 VertexArray.o: VertexArray.cpp VertexArray.h ../Geo/SVector3.h \
diff --git a/Fltk/Makefile b/Fltk/Makefile
index 08da4b8587783b5abea2dfdf4ae70d95d9a47aa9..7eb7d3f07006dfef6c38ac8afe7a39d96bb8f403 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.158 2008-01-19 22:06:01 geuzaine Exp $
+# $Id: Makefile,v 1.159 2008-01-19 23:04:12 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -121,16 +121,15 @@ GUI_Projection.o: GUI_Projection.cpp ../Geo/GModelIO_F.h ../Geo/GModel.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  ../Graphics/Draw.h ../Common/Options.h ../Post/ColorTable.h \
-  ../Parser/OpenFile.h ../Graphics/SelectBuffer.h GUI_Projection.h \
-  ../Common/GmshUI.h ../Geo/FProjectionFace.h ../Geo/GModel.h \
-  ../Geo/Range.h GUI.h Opengl_Window.h Colorbar_Window.h Popup_Button.h \
-  SpherePosition_Widget.h Shortcut_Window.h GUI_Extras.h ../Geo/FFace.h \
-  ../Geo/GFace.h ../Geo/GModel.h ../Geo/Range.h ../Geo/FEdge.h \
-  ../Geo/GEdge.h ../Geo/GModel.h ../Geo/FVertex.h ../Geo/GModel.h \
-  ../Geo/GVertex.h ../Geo/Range.h ../Common/Message.h
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Graphics/Draw.h \
+  ../Common/Options.h ../Post/ColorTable.h ../Common/Context.h \
+  ../DataStr/List.h ../Parser/OpenFile.h ../Graphics/SelectBuffer.h \
+  GUI_Projection.h ../Common/GmshUI.h ../Geo/FProjectionFace.h \
+  ../Geo/GModel.h ../Geo/Range.h GUI.h Opengl_Window.h Colorbar_Window.h \
+  Popup_Button.h SpherePosition_Widget.h Shortcut_Window.h GUI_Extras.h \
+  ../Geo/FFace.h ../Geo/GFace.h ../Geo/GModel.h ../Geo/Range.h \
+  ../Geo/FEdge.h ../Geo/GEdge.h ../Geo/GModel.h ../Geo/FVertex.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/Range.h ../Common/Message.h
 GUI_Classifier.o: GUI_Classifier.cpp GUI_Classifier.h ../Common/GmshUI.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
@@ -141,18 +140,18 @@ GUI_Classifier.o: GUI_Classifier.cpp GUI_Classifier.h ../Common/GmshUI.h \
   ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h \
   ../Geo/GEntity.h ../Geo/SBoundingBox3d.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h GUI.h Opengl_Window.h \
-  Colorbar_Window.h ../Post/ColorTable.h Popup_Button.h \
-  SpherePosition_Widget.h Shortcut_Window.h ../Graphics/Draw.h \
-  ../Common/Options.h ../Graphics/SelectBuffer.h GUI_Projection.h \
-  ../Geo/FProjectionFace.h ../Geo/GModel.h ../Geo/Range.h GUI_Extras.h \
-  ../Common/Message.h ../Mesh/meshGFaceDelaunayInsertion.h \
-  ../Mesh/meshGFaceOptimize.h ../Mesh/meshGFaceDelaunayInsertion.h \
-  ../Geo/gmshEdge.h ../Geo/Geo.h ../Geo/gmshSurface.h ../Geo/Pair.h \
-  ../Geo/Range.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \
-  ../Geo/SBoundingBox3d.h ../DataStr/Tree.h ../DataStr/avl.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h GUI.h Opengl_Window.h Colorbar_Window.h \
+  ../Post/ColorTable.h Popup_Button.h SpherePosition_Widget.h \
+  Shortcut_Window.h ../Graphics/Draw.h ../Common/Options.h \
+  ../Common/Context.h ../DataStr/List.h ../Graphics/SelectBuffer.h \
+  GUI_Projection.h ../Geo/FProjectionFace.h ../Geo/GModel.h \
+  ../Geo/Range.h GUI_Extras.h ../Common/Message.h \
+  ../Mesh/meshGFaceDelaunayInsertion.h ../Mesh/meshGFaceOptimize.h \
+  ../Mesh/meshGFaceDelaunayInsertion.h ../Geo/gmshEdge.h ../Geo/Geo.h \
+  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
+  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SBoundingBox3d.h \
+  ../Numeric/Numeric.h ../DataStr/Tree.h ../DataStr/avl.h \
   ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
   ../Geo/GEdge.h ../Geo/gmshVertex.h ../Geo/Geo.h ../Geo/GVertex.h \
   ../Geo/Range.h ../Geo/gmshFace.h ../Geo/Geo.h ../Geo/GFace.h \
@@ -169,13 +168,13 @@ Callbacks.o: Callbacks.cpp ../Common/GmshUI.h ../Common/Message.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../Geo/GeoStringInterface.h \
-  ../Geo/findLinks.h ../Mesh/Generator.h ../Mesh/HighOrder.h \
-  ../Graphics/Draw.h ../Graphics/SelectBuffer.h ../Post/PView.h \
-  ../Common/SmoothData.h ../Post/PViewData.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h ../Parser/CreateFile.h ../Parser/OpenFile.h \
-  ../Common/CommandLine.h ../Common/Options.h GUI.h Opengl_Window.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/GeoStringInterface.h ../Geo/findLinks.h ../Mesh/Generator.h \
+  ../Mesh/HighOrder.h ../Graphics/Draw.h ../Graphics/SelectBuffer.h \
+  ../Post/PView.h ../Common/SmoothData.h ../Numeric/Numeric.h \
+  ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Parser/CreateFile.h ../Parser/OpenFile.h ../Common/CommandLine.h \
+  ../Common/Context.h ../Common/Options.h GUI.h Opengl_Window.h \
   Colorbar_Window.h Popup_Button.h SpherePosition_Widget.h GUI_Extras.h \
   Callbacks.h ../Plugin/Plugin.h ../Post/PViewDataList.h \
   ../Post/PViewData.h ../Post/AdaptiveViews.h ../Common/GmshMatrix.h \
@@ -212,8 +211,8 @@ Opengl_Window.o: Opengl_Window.cpp ../Common/GmshUI.h \
   ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h GUI.h Opengl_Window.h \
   Colorbar_Window.h ../Post/ColorTable.h Popup_Button.h \
   SpherePosition_Widget.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h
 Colorbar_Window.o: Colorbar_Window.cpp ../Common/GmshUI.h GUI.h \
   Opengl_Window.h Colorbar_Window.h ../Post/ColorTable.h Popup_Button.h \
   SpherePosition_Widget.h ../Common/Context.h ../DataStr/List.h
diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index 5b6b5c289afe61fdcff90333ae673e6b60e29ec3..0ef09179a51599d882ba347df1811bea57999c0e 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -1,4 +1,4 @@
-// $Id: GModel.cpp,v 1.53 2008-01-19 22:06:01 geuzaine Exp $
+// $Id: GModel.cpp,v 1.54 2008-01-19 23:04:12 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -25,6 +25,9 @@
 #include "Field.h"
 #include "BackgroundMesh.h"
 #include "Message.h"
+#include "Context.h"
+
+extern Context_T CTX;
 
 std::vector<GModel*> GModel::list;
 
diff --git a/Geo/MEdge.h b/Geo/MEdge.h
index a37a6a82de2f14d920f5424c2f36ed21c17603b9..08fbadfed55c70450323d21ff0b2ed594e4860e9 100644
--- a/Geo/MEdge.h
+++ b/Geo/MEdge.h
@@ -23,7 +23,6 @@
 #include <functional>
 #include "MVertex.h"
 #include "SVector3.h"
-#include "Hash.h"
 
 // A mesh edge.
 class MEdge {
@@ -83,17 +82,12 @@ class MEdge {
   }
 };
 
-//--Operators for comparing edges
-
 inline bool operator!=(const MEdge &e1, const MEdge &e2)
 {
   return (e1.getMinVertex() != e2.getMinVertex() ||
           e1.getMaxVertex() != e2.getMaxVertex());
 }
   
-//--The following function objects compare the addresses of the mesh vertices.
-//--Equal, Less, and a Hash are defined.
-
 struct Equal_Edge : public std::binary_function<MEdge, MEdge, bool> {
   bool operator()(const MEdge &e1, const MEdge &e2) const
   {
@@ -112,14 +106,4 @@ struct Less_Edge : public std::binary_function<MEdge, MEdge, bool> {
   }
 };
 
-struct Hash_Edge : public std::unary_function<MEdge, size_t> {
-  size_t operator()(const MEdge &e) const
-  {
-    const MVertex *v[2];
-    v[0] = e.getMinVertex();
-    v[1] = e.getMaxVertex();
-    return HashFNV1a<sizeof(MVertex*[2])>::eval(v);
-  }
-};
-
 #endif
diff --git a/Geo/MEdgeHash.h b/Geo/MEdgeHash.h
new file mode 100644
index 0000000000000000000000000000000000000000..d799bce8d0dc9449821a1d2b8f239fb702e41fb2
--- /dev/null
+++ b/Geo/MEdgeHash.h
@@ -0,0 +1,17 @@
+#ifndef _MEDGE_HASH_H_
+#define _MEDGE_HASH_H_
+
+#include "MEdge.h"
+#include "Hash.h"
+
+struct Hash_Edge : public std::unary_function<MEdge, size_t> {
+  size_t operator()(const MEdge &e) const
+  {
+    const MVertex *v[2];
+    v[0] = e.getMinVertex();
+    v[1] = e.getMaxVertex();
+    return HashFNV1a<sizeof(MVertex*[2])>::eval(v);
+  }
+};
+
+#endif
diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp
index b8dd27abaffea06a324f035b37bccaa829c364f3..ed176af77aa6ea2dea9387f98db780a898f13a6b 100644
--- a/Geo/MElement.cpp
+++ b/Geo/MElement.cpp
@@ -1,4 +1,4 @@
-// $Id: MElement.cpp,v 1.47 2008-01-14 21:29:13 remacle Exp $
+// $Id: MElement.cpp,v 1.48 2008-01-19 23:04:12 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -114,6 +114,113 @@ double MTetrahedron::etaShapeMeasure()
   return qmTet(this,QMTET_3,&vol);
 }
 
+void MTetrahedron::getMat(double mat[3][3])
+{
+  mat[0][0] = _v[1]->x() - _v[0]->x();
+  mat[0][1] = _v[2]->x() - _v[0]->x();
+  mat[0][2] = _v[3]->x() - _v[0]->x();
+  mat[1][0] = _v[1]->y() - _v[0]->y();
+  mat[1][1] = _v[2]->y() - _v[0]->y();
+  mat[1][2] = _v[3]->y() - _v[0]->y();
+  mat[2][0] = _v[1]->z() - _v[0]->z();
+  mat[2][1] = _v[2]->z() - _v[0]->z();
+  mat[2][2] = _v[3]->z() - _v[0]->z();
+}
+
+double MTetrahedron::getVolume()
+{ 
+  double mat[3][3];
+  getMat(mat);
+  return det3x3(mat) / 6.;
+}
+
+bool MTetrahedron::invertmapping(double *p, double *uvw, double tol)
+{
+  double mat[3][3];
+  double b[3], dum;
+  getMat(mat);
+  b[0] = p[0] - getVertex(0)->x();
+  b[1] = p[1] - getVertex(0)->y();
+  b[2] = p[2] - getVertex(0)->z();
+  sys3x3(mat, b, uvw, &dum);
+  if(uvw[0] >= -tol && uvw[1] >= -tol && uvw[2] >= -tol &&
+     uvw[0] <= 1. + tol && uvw[1] <= 1. + tol && uvw[2] <= 1. + tol &&
+     1. - uvw[0] - uvw[1] - uvw[2] > -tol) {
+    return true;
+  }
+  return false;
+}
+
+void MTetrahedron::circumcenter(double X[4], double Y[4], double Z[4], double *res)
+{
+  double mat[3][3], b[3], dum;    
+  b[0] = X[1] * X[1] - X[0] * X[0] +
+    Y[1] * Y[1] - Y[0] * Y[0] + Z[1] * Z[1] - Z[0] * Z[0];
+  b[1] = X[2] * X[2] - X[1] * X[1] +
+    Y[2] * Y[2] - Y[1] * Y[1] + Z[2] * Z[2] - Z[1] * Z[1];
+  b[2] = X[3] * X[3] - X[2] * X[2] +
+    Y[3] * Y[3] - Y[2] * Y[2] + Z[3] * Z[3] - Z[2] * Z[2];
+  for(int i = 0; i < 3; i++)
+    b[i] *= 0.5;
+  mat[0][0] = X[1] - X[0];
+  mat[0][1] = Y[1] - Y[0];
+  mat[0][2] = Z[1] - Z[0];
+  mat[1][0] = X[2] - X[1];
+  mat[1][1] = Y[2] - Y[1];
+  mat[1][2] = Z[2] - Z[1];
+  mat[2][0] = X[3] - X[2];
+  mat[2][1] = Y[3] - Y[2];
+  mat[2][2] = Z[3] - Z[2];
+  if(!sys3x3(mat, b, res, &dum)) {
+    res[0] = res[1] = res[2] = 10.0e10;
+  }
+}
+
+int MHexahedron::getVolumeSign()
+{ 
+  double mat[3][3];
+  mat[0][0] = _v[1]->x() - _v[0]->x();
+  mat[0][1] = _v[3]->x() - _v[0]->x();
+  mat[0][2] = _v[4]->x() - _v[0]->x();
+  mat[1][0] = _v[1]->y() - _v[0]->y();
+  mat[1][1] = _v[3]->y() - _v[0]->y();
+  mat[1][2] = _v[4]->y() - _v[0]->y();
+  mat[2][0] = _v[1]->z() - _v[0]->z();
+  mat[2][1] = _v[3]->z() - _v[0]->z();
+  mat[2][2] = _v[4]->z() - _v[0]->z();
+  return sign(det3x3(mat));
+}
+
+int MPrism::getVolumeSign()
+{ 
+  double mat[3][3];
+  mat[0][0] = _v[1]->x() - _v[0]->x();
+  mat[0][1] = _v[2]->x() - _v[0]->x();
+  mat[0][2] = _v[3]->x() - _v[0]->x();
+  mat[1][0] = _v[1]->y() - _v[0]->y();
+  mat[1][1] = _v[2]->y() - _v[0]->y();
+  mat[1][2] = _v[3]->y() - _v[0]->y();
+  mat[2][0] = _v[1]->z() - _v[0]->z();
+  mat[2][1] = _v[2]->z() - _v[0]->z();
+  mat[2][2] = _v[3]->z() - _v[0]->z();
+  return sign(det3x3(mat));
+}
+
+int MPyramid::getVolumeSign()
+{ 
+  double mat[3][3];
+  mat[0][0] = _v[1]->x() - _v[0]->x();
+  mat[0][1] = _v[3]->x() - _v[0]->x();
+  mat[0][2] = _v[4]->x() - _v[0]->x();
+  mat[1][0] = _v[1]->y() - _v[0]->y();
+  mat[1][1] = _v[3]->y() - _v[0]->y();
+  mat[1][2] = _v[4]->y() - _v[0]->y();
+  mat[2][0] = _v[1]->z() - _v[0]->z();
+  mat[2][1] = _v[3]->z() - _v[0]->z();
+  mat[2][2] = _v[4]->z() - _v[0]->z();
+  return sign(det3x3(mat));
+}
+
 SPoint3 MElement::barycenter()
 {
   SPoint3 p(0., 0., 0.);
diff --git a/Geo/MElement.h b/Geo/MElement.h
index bb7b4b9498c17585cf5edb544d42f259c7442425..99fdc4aed3b6e36ebd68a310c540bd8c92a24fdc 100644
--- a/Geo/MElement.h
+++ b/Geo/MElement.h
@@ -753,69 +753,15 @@ class MTetrahedron : public MElement {
   {
     MVertex *tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp;
   }
-  virtual void  getMat(double mat[3][3])
-  {
-    mat[0][0] = _v[1]->x() - _v[0]->x();
-    mat[0][1] = _v[2]->x() - _v[0]->x();
-    mat[0][2] = _v[3]->x() - _v[0]->x();
-    mat[1][0] = _v[1]->y() - _v[0]->y();
-    mat[1][1] = _v[2]->y() - _v[0]->y();
-    mat[1][2] = _v[3]->y() - _v[0]->y();
-    mat[2][0] = _v[1]->z() - _v[0]->z();
-    mat[2][1] = _v[2]->z() - _v[0]->z();
-    mat[2][2] = _v[3]->z() - _v[0]->z();
-  }
-  virtual double getVolume()
-  { 
-    double mat[3][3];
-    getMat(mat);
-    return det3x3(mat) / 6.;
-  }
-  virtual int getVolumeSign(){ return sign(getVolume()); }
+  virtual void  getMat(double mat[3][3]);
+  virtual double getVolume();
+  virtual int getVolumeSign(){ return (getVolume() >= 0) ? 1 : -1; }
   virtual double gammaShapeMeasure();
   virtual double etaShapeMeasure();
   // returns true if the point lies inside the tet
-  inline bool invertmapping(double *p, double *uvw, double tol = 1.e-8)
-  {
-    double mat[3][3];
-    double b[3], dum;
-    getMat(mat);
-    b[0] = p[0] - getVertex(0)->x();
-    b[1] = p[1] - getVertex(0)->y();
-    b[2] = p[2] - getVertex(0)->z();
-    sys3x3(mat, b, uvw, &dum);
-    if(uvw[0] >= -tol && uvw[1] >= -tol && uvw[2] >= -tol &&
-       uvw[0] <= 1. + tol && uvw[1] <= 1. + tol && uvw[2] <= 1. + tol &&
-       1. - uvw[0] - uvw[1] - uvw[2] > -tol) {
-      return true;
-    }
-    return false;
-  }
-  inline static void circumcenter(double X[4],double Y[4],double Z[4],double *res)
-  {
-    double mat[3][3], b[3], dum;    
-    b[0] = X[1] * X[1] - X[0] * X[0] +
-      Y[1] * Y[1] - Y[0] * Y[0] + Z[1] * Z[1] - Z[0] * Z[0];
-    b[1] = X[2] * X[2] - X[1] * X[1] +
-      Y[2] * Y[2] - Y[1] * Y[1] + Z[2] * Z[2] - Z[1] * Z[1];
-    b[2] = X[3] * X[3] - X[2] * X[2] +
-      Y[3] * Y[3] - Y[2] * Y[2] + Z[3] * Z[3] - Z[2] * Z[2];
-    for(int i = 0; i < 3; i++)
-      b[i] *= 0.5;
-    mat[0][0] = X[1] - X[0];
-    mat[0][1] = Y[1] - Y[0];
-    mat[0][2] = Z[1] - Z[0];
-    mat[1][0] = X[2] - X[1];
-    mat[1][1] = Y[2] - Y[1];
-    mat[1][2] = Z[2] - Z[1];
-    mat[2][0] = X[3] - X[2];
-    mat[2][1] = Y[3] - Y[2];
-    mat[2][2] = Z[3] - Z[2];
-    if(!sys3x3(mat, b, res, &dum)) {
-      res[0] = res[1] = res[2] = 10.0e10;
-    }
-  }
-  inline void circumcenter(double *res)
+  bool invertmapping(double *p, double *uvw, double tol = 1.e-8);
+  static void circumcenter(double X[4],double Y[4],double Z[4],double *res);
+  void circumcenter(double *res)
   {
     double X[4] = {_v[0]->x(), _v[1]->x(), _v[2]->x(), _v[3]->x()};
     double Y[4] = {_v[0]->y(), _v[1]->y(), _v[2]->y(), _v[3]->y()};
@@ -982,20 +928,7 @@ class MHexahedron : public MElement {
     tmp = _v[0]; _v[0] = _v[2]; _v[2] = tmp;
     tmp = _v[4]; _v[4] = _v[6]; _v[6] = tmp;
   }
-  virtual int getVolumeSign()
-  { 
-    double mat[3][3];
-    mat[0][0] = _v[1]->x() - _v[0]->x();
-    mat[0][1] = _v[3]->x() - _v[0]->x();
-    mat[0][2] = _v[4]->x() - _v[0]->x();
-    mat[1][0] = _v[1]->y() - _v[0]->y();
-    mat[1][1] = _v[3]->y() - _v[0]->y();
-    mat[1][2] = _v[4]->y() - _v[0]->y();
-    mat[2][0] = _v[1]->z() - _v[0]->z();
-    mat[2][1] = _v[3]->z() - _v[0]->z();
-    mat[2][2] = _v[4]->z() - _v[0]->z();
-    return sign(det3x3(mat));
-  }
+  virtual int getVolumeSign();
 };
 
 class MHexahedron20 : public MHexahedron {
@@ -1266,20 +1199,7 @@ class MPrism : public MElement {
     tmp = _v[0]; _v[0] = _v[1]; _v[1] = tmp;
     tmp = _v[3]; _v[3] = _v[4]; _v[4] = tmp;
   }
-  virtual int getVolumeSign()
-  { 
-    double mat[3][3];
-    mat[0][0] = _v[1]->x() - _v[0]->x();
-    mat[0][1] = _v[2]->x() - _v[0]->x();
-    mat[0][2] = _v[3]->x() - _v[0]->x();
-    mat[1][0] = _v[1]->y() - _v[0]->y();
-    mat[1][1] = _v[2]->y() - _v[0]->y();
-    mat[1][2] = _v[3]->y() - _v[0]->y();
-    mat[2][0] = _v[1]->z() - _v[0]->z();
-    mat[2][1] = _v[2]->z() - _v[0]->z();
-    mat[2][2] = _v[3]->z() - _v[0]->z();
-    return sign(det3x3(mat));
-  }
+  virtual int getVolumeSign();
 };
 
 class MPrism15 : public MPrism {
@@ -1515,20 +1435,7 @@ class MPyramid : public MElement {
   {
     MVertex *tmp = _v[0]; _v[0] = _v[2]; _v[2] = tmp;
   }
-  virtual int getVolumeSign()
-  { 
-    double mat[3][3];
-    mat[0][0] = _v[1]->x() - _v[0]->x();
-    mat[0][1] = _v[3]->x() - _v[0]->x();
-    mat[0][2] = _v[4]->x() - _v[0]->x();
-    mat[1][0] = _v[1]->y() - _v[0]->y();
-    mat[1][1] = _v[3]->y() - _v[0]->y();
-    mat[1][2] = _v[4]->y() - _v[0]->y();
-    mat[2][0] = _v[1]->z() - _v[0]->z();
-    mat[2][1] = _v[3]->z() - _v[0]->z();
-    mat[2][2] = _v[4]->z() - _v[0]->z();
-    return sign(det3x3(mat));
-  }
+  virtual int getVolumeSign();
 };
 
 class MPyramid13 : public MPyramid {
diff --git a/Geo/MFace.cpp b/Geo/MFace.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47a87f7810a429ca3ebee4991c6a22890fa764f0
--- /dev/null
+++ b/Geo/MFace.cpp
@@ -0,0 +1,89 @@
+// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+// 
+// Please report all bugs and problems to <gmsh@geuz.org>.
+
+#include "MFace.h"
+#include "Numeric.h"
+#include "Context.h"
+
+extern Context_T CTX;
+
+MFace::MFace(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3) 
+{
+  if(CTX.mesh.reverse_all_normals){
+    // Note that we cannot simply change the normal computation,
+    // since OpenGL wants the normal to a polygon to be coherent
+    // with the ordering of its vertices
+    if(v3){
+      _v[0] = v0; _v[1] = v3; _v[2] = v2; _v[3] = v1;
+    }
+    else{
+      _v[0] = v0; _v[1] = v2; _v[2] = v1; _v[3] = v3;
+    }
+  }
+  else{
+    _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3;
+  }
+  // This is simply an unrolled insertion sort (hopefully fast).  Note that if
+  // _v[3] == 0, _v[3] is not sorted.
+  if(_v[1] < _v[0]) {
+    _si[0] = 1;
+    _si[1] = 0;
+  }
+  else {
+    _si[0] = 0;
+    _si[1] = 1;
+  }
+  if(_v[2] < _v[int(_si[1])]) {
+    _si[2] = _si[1];
+    if(_v[2] < _v[int(_si[0])]) {
+      _si[1] = _si[0];
+      _si[0] = 2;
+    }
+    else
+      _si[1] = 2;
+  }
+  else
+    _si[2] = 2;
+  if( _v[3] && _v[3] < _v[int(_si[2])]) {
+    _si[3] = _si[2];
+    if(_v[3] < _v[int(_si[1])]) {
+      _si[2] = _si[1];
+      if(_v[3] < _v[int(_si[0])]) {
+	_si[1] = _si[0];
+	_si[0] = 3;
+      }
+      else
+	_si[1] = 3;
+    }
+    else
+      _si[2] = 3;
+  }
+  else
+    _si[3] = 3;
+}
+
+SVector3 MFace::normal() const
+{
+  double n[3];
+  normal3points(_v[0]->x(), _v[0]->y(), _v[0]->z(),
+		_v[1]->x(), _v[1]->y(), _v[1]->z(),
+		_v[2]->x(), _v[2]->y(), _v[2]->z(), n);
+  return SVector3(n[0], n[1], n[2]);
+}
+
diff --git a/Geo/MFace.h b/Geo/MFace.h
index 0503d97a2e100a04d3470e655dfa83175a79da3e..f72c3384129d40015562551046889541cc563ecd 100644
--- a/Geo/MFace.h
+++ b/Geo/MFace.h
@@ -24,11 +24,6 @@
 #include <vector>
 #include "MVertex.h"
 #include "SVector3.h"
-#include "Numeric.h"
-#include "Context.h"
-#include "Hash.h"
-
-extern Context_T CTX;
 
 // A mesh face.
 class MFace {
@@ -37,60 +32,7 @@ class MFace {
   char _si[4];                          // sorted indices
 
  public:
-  MFace(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3=0) 
-  {
-    if(CTX.mesh.reverse_all_normals){
-      // Note that we cannot simply change the normal computation,
-      // since OpenGL wants the normal to a polygon to be coherent
-      // with the ordering of its vertices
-      if(v3){
-	_v[0] = v0; _v[1] = v3; _v[2] = v2; _v[3] = v1;
-      }
-      else{
-	_v[0] = v0; _v[1] = v2; _v[2] = v1; _v[3] = v3;
-      }
-    }
-    else{
-      _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3;
-    }
-    // This is simply an unrolled insertion sort (hopefully fast).  Note that if
-    // _v[3] == 0, _v[3] is not sorted.
-    if(_v[1] < _v[0]) {
-      _si[0] = 1;
-      _si[1] = 0;
-    }
-    else {
-      _si[0] = 0;
-      _si[1] = 1;
-    }
-    if(_v[2] < _v[int(_si[1])]) {
-      _si[2] = _si[1];
-      if(_v[2] < _v[int(_si[0])]) {
-        _si[1] = _si[0];
-        _si[0] = 2;
-      }
-      else
-        _si[1] = 2;
-    }
-    else
-      _si[2] = 2;
-    if( _v[3] && _v[3] < _v[int(_si[2])]) {
-      _si[3] = _si[2];
-      if(_v[3] < _v[int(_si[1])]) {
-        _si[2] = _si[1];
-        if(_v[3] < _v[int(_si[0])]) {
-          _si[1] = _si[0];
-          _si[0] = 3;
-        }
-        else
-          _si[1] = 3;
-      }
-      else
-        _si[2] = 3;
-    }
-    else
-      _si[3] = 3;
-  }
+  MFace(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3=0);
   inline int getNumVertices() const { return _v[3] ? 4 : 3; }
   inline MVertex *getVertex(const int i) const { return _v[i]; }
   inline MVertex *getSortedVertex(const int i) const { return _v[int(_si[i])]; }
@@ -106,14 +48,7 @@ class MFace {
     verts[2] = getSortedVertex(2);
     verts[3] = getSortedVertex(3);
   }
-  SVector3 normal() const
-  {
-    double n[3];
-    normal3points(_v[0]->x(), _v[0]->y(), _v[0]->z(),
-		  _v[1]->x(), _v[1]->y(), _v[1]->z(),
-		  _v[2]->x(), _v[2]->y(), _v[2]->z(), n);
-    return SVector3(n[0], n[1], n[2]);
-  }
+  SVector3 normal() const;
   SVector3 tangent(int num) const
   {
     SVector3 t0(_v[1]->x() - _v[0]->x(), 
@@ -170,9 +105,6 @@ class MFace {
   }
 };
 
-//--The following function objects compare the addresses of the mesh vertices.
-//--Equal, Less, and a Hash are defined.
-
 struct Equal_Face : public std::binary_function<MFace, MFace, bool> {
   bool operator()(const MFace &f1, const MFace &f2) const
   {
@@ -197,13 +129,4 @@ struct Less_Face : public std::binary_function<MFace, MFace, bool> {
   }
 };
 
-struct Hash_Face : public std::unary_function<MFace, size_t> {
-  size_t operator()(const MFace &f) const
-  {
-    const MVertex *v[4];
-    f.getOrderedVertices(v);
-    return HashFNV1a<sizeof(MVertex*[4])>::eval(v);
-  }
-};
-
 #endif
diff --git a/Geo/MFaceHash.h b/Geo/MFaceHash.h
new file mode 100644
index 0000000000000000000000000000000000000000..3010460816727152c092bbd707e1bbc6b49c4139
--- /dev/null
+++ b/Geo/MFaceHash.h
@@ -0,0 +1,16 @@
+#ifndef _MFACE_HASH_H_
+#define _MFACE_HASH_H_
+
+#include "MFace.h"
+#include "Hash.h"
+
+struct Hash_Face : public std::unary_function<MFace, size_t> {
+  size_t operator()(const MFace &f) const
+  {
+    const MVertex *v[4];
+    f.getOrderedVertices(v);
+    return HashFNV1a<sizeof(MVertex*[4])>::eval(v);
+  }
+};
+
+#endif
diff --git a/Geo/MNeighbour.h b/Geo/MNeighbour.h
index c12f99d26a233adc58bd2e662daaad145854b742..c2bb20f8ab866901a7b9eda0307f7cdc44482dfa 100644
--- a/Geo/MNeighbour.h
+++ b/Geo/MNeighbour.h
@@ -37,6 +37,8 @@
 #include "GEdge.h"
 #include "GFace.h"
 #include "GRegion.h"
+#include "MEdgeHash.h"
+#include "MFaceHash.h"
 #include "GmshDefines.h"
 
 // #define HAVE_HASH_MAP
diff --git a/Geo/Makefile b/Geo/Makefile
index c0dff40735428dedd929a88a3a8d7a14ce861ce0..3172e2e9782fd5d78bd8f81db7dd97f75b052ba7 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.172 2008-01-19 22:06:02 geuzaine Exp $
+# $Id: Makefile,v 1.173 2008-01-19 23:04:12 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -45,7 +45,8 @@ SRC = GEntity.cpp\
       Geo.cpp \
 	GeoStringInterface.cpp GeoInterpolation.cpp\
       findLinks.cpp\
-      MVertex.cpp \
+      MVertex.cpp\
+      MFace.cpp\
       MElement.cpp
 
 OBJ = ${SRC:.cpp=${OBJEXT}}
@@ -80,21 +81,19 @@ GVertex.o: GVertex.cpp GVertex.h GEntity.h Range.h SPoint3.h \
 GEdge.o: GEdge.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h SVector3.h \
   GFace.h GEdgeLoop.h Pair.h GRegion.h MElement.h ../Common/GmshDefines.h \
-  MEdge.h ../Common/Hash.h MFace.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h
+  MEdge.h MFace.h
 GEdgeLoop.o: GEdgeLoop.cpp GEdgeLoop.h GEdge.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h GVertex.h MVertex.h GPoint.h SPoint2.h \
   SVector3.h ../Common/Message.h
 GFace.o: GFace.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h SVector3.h \
   GFace.h GEdgeLoop.h Pair.h GRegion.h MElement.h ../Common/GmshDefines.h \
-  MEdge.h ../Common/Hash.h MFace.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Common/Message.h
+  MEdge.h MFace.h ../Common/Message.h ../Numeric/Numeric.h \
+  ../Common/Context.h ../DataStr/List.h
 GRegion.o: GRegion.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h SVector3.h \
   GFace.h GEdgeLoop.h Pair.h GRegion.h MElement.h ../Common/GmshDefines.h \
-  MEdge.h ../Common/Hash.h MFace.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h
+  MEdge.h MFace.h
 gmshVertex.o: gmshVertex.cpp GFace.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h GPoint.h GEdgeLoop.h GEdge.h GVertex.h MVertex.h \
   SPoint2.h SVector3.h Pair.h gmshVertex.h Geo.h ../Common/GmshDefines.h \
@@ -158,14 +157,13 @@ FProjectionFace.o: FProjectionFace.cpp FProjectionFace.h GModel.h \
 GModel.o: GModel.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h SVector3.h \
   GFace.h GEdgeLoop.h Pair.h GRegion.h gmshSurface.h ../Numeric/Numeric.h \
-  MElement.h ../Common/GmshDefines.h MEdge.h ../Common/Hash.h MFace.h \
-  ../Common/Context.h ../DataStr/List.h ../Mesh/Field.h ../Post/PView.h \
-  ../Common/SmoothData.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Geo/Geo.h \
-  ../Geo/gmshSurface.h ../DataStr/Tree.h ../DataStr/avl.h \
-  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Geo/GEdge.h \
+  MElement.h ../Common/GmshDefines.h MEdge.h MFace.h ../Mesh/Field.h \
+  ../Post/PView.h ../Common/SmoothData.h ../Post/PViewData.h \
+  ../Geo/SBoundingBox3d.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Geo/Geo.h ../Geo/gmshSurface.h ../DataStr/List.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Geo/GEdge.h \
   ../Post/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h \
-  ../Mesh/BackgroundMesh.h ../Common/Message.h
+  ../Mesh/BackgroundMesh.h ../Common/Message.h ../Common/Context.h
 GModelIO_Geo.o: GModelIO_Geo.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h \
   SVector3.h GFace.h GEdgeLoop.h Pair.h GRegion.h Geo.h \
@@ -180,8 +178,7 @@ GModelIO_Mesh.o: GModelIO_Mesh.cpp ../Common/Message.h \
   GFace.h GEdgeLoop.h Pair.h GRegion.h gmshRegion.h Geo.h gmshSurface.h \
   ../Numeric/Numeric.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ExtrudeParams.h ../Common/SmoothData.h gmshFace.h \
-  gmshVertex.h gmshEdge.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
-  ../Common/Context.h
+  gmshVertex.h gmshEdge.h MElement.h MEdge.h MFace.h
 GModelIO_OCC.o: GModelIO_OCC.cpp GModelIO_OCC.h GModel.h GVertex.h \
   GEntity.h Range.h SPoint3.h SBoundingBox3d.h MVertex.h GPoint.h \
   SPoint2.h GEdge.h SVector3.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
@@ -194,12 +191,12 @@ GModelIO_F.o: GModelIO_F.cpp GModel.h GVertex.h GEntity.h Range.h \
 GModelIO_CGNS.o: GModelIO_CGNS.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h \
   SVector3.h GFace.h GEdgeLoop.h Pair.h GRegion.h ../Common/Message.h \
-  MElement.h ../Common/GmshDefines.h MEdge.h ../Common/Hash.h MFace.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h MNeighbour.h
+  MElement.h ../Common/GmshDefines.h MEdge.h MFace.h MNeighbour.h \
+  MEdgeHash.h ../Common/Hash.h MFaceHash.h
 GModelIO_MED.o: GModelIO_MED.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h \
   SVector3.h GFace.h GEdgeLoop.h Pair.h GRegion.h MEdge.h \
-  ../Common/Hash.h ../Common/Message.h
+  ../Common/Message.h
 ExtrudeParams.o: ExtrudeParams.cpp ../Common/Message.h Geo.h \
   ../Common/GmshDefines.h gmshSurface.h Pair.h Range.h SPoint2.h \
   SPoint3.h SVector3.h SBoundingBox3d.h ../Numeric/Numeric.h \
@@ -233,8 +230,10 @@ findLinks.o: findLinks.cpp ../Common/Message.h GModel.h GVertex.h \
 MVertex.o: MVertex.cpp MVertex.h SPoint3.h GEdge.h GEntity.h Range.h \
   SBoundingBox3d.h GVertex.h GPoint.h SPoint2.h SVector3.h GFace.h \
   GEdgeLoop.h Pair.h
+MFace.o: MFace.cpp MFace.h MVertex.h SPoint3.h SVector3.h \
+  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h
 MElement.o: MElement.cpp MElement.h ../Common/GmshDefines.h MVertex.h \
-  SPoint3.h MEdge.h SVector3.h ../Common/Hash.h MFace.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h GEntity.h \
-  Range.h SBoundingBox3d.h GFace.h GPoint.h GEdgeLoop.h GEdge.h GVertex.h \
-  SPoint2.h Pair.h ../Common/Message.h ../Mesh/qualityMeasures.h
+  SPoint3.h MEdge.h SVector3.h MFace.h GEntity.h Range.h SBoundingBox3d.h \
+  GFace.h GPoint.h GEdgeLoop.h GEdge.h GVertex.h SPoint2.h Pair.h \
+  ../Numeric/Numeric.h ../Common/Message.h ../Common/Context.h \
+  ../DataStr/List.h ../Mesh/qualityMeasures.h
diff --git a/Graphics/Makefile b/Graphics/Makefile
index 21972467e19922221a1d056588f7bd7d9089fdee..735fa7ed88e812b2020eae8860b14270c081fec2 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.132 2008-01-19 22:06:02 geuzaine Exp $
+# $Id: Makefile,v 1.133 2008-01-19 23:04:13 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -90,10 +90,10 @@ Mesh.o: Mesh.cpp ../Common/Message.h ../Common/GmshUI.h ../Geo/GModel.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h Draw.h \
-  ../Common/OS.h gl2ps.h ../Common/VertexArray.h ../Common/Context.h \
-  ../Common/SmoothData.h
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h Draw.h \
+  ../Common/Context.h ../DataStr/List.h ../Common/OS.h gl2ps.h \
+  ../Common/VertexArray.h ../Common/Context.h ../Common/SmoothData.h \
+  ../Numeric/Numeric.h
 Geom.o: Geom.cpp ../Common/GmshUI.h Draw.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Common/Context.h ../DataStr/List.h gl2ps.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
@@ -120,10 +120,10 @@ SelectBuffer.o: SelectBuffer.cpp ../Common/Message.h ../Common/GmshUI.h \
   ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h Draw.h SelectBuffer.h \
-  ../Common/VertexArray.h ../Common/Context.h
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h Draw.h ../Common/Context.h \
+  ../DataStr/List.h SelectBuffer.h ../Common/VertexArray.h \
+  ../Common/Context.h
 Iso.o: Iso.cpp ../Numeric/Numeric.h
 Entity.o: Entity.cpp ../Common/GmshUI.h ../Numeric/Numeric.h Draw.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/Context.h \
diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp
index 13632b7017fa9836f384dae8726056a67f79f148..9c8f5330c958ccf61a7e8fbbd1776c2d371b552b 100644
--- a/Mesh/HighOrder.cpp
+++ b/Mesh/HighOrder.cpp
@@ -1,4 +1,4 @@
-// $Id: HighOrder.cpp,v 1.16 2008-01-14 21:29:14 remacle Exp $
+// $Id: HighOrder.cpp,v 1.17 2008-01-19 23:04:13 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -24,6 +24,10 @@
 #include "MElement.h"
 #include "Message.h"
 #include "OS.h"
+#include "Numeric.h"
+#include "Context.h"
+
+extern Context_T CTX;
 
 void computeMidPoints(const double *p1,
 		      const double *p2, 
diff --git a/Mesh/Makefile b/Mesh/Makefile
index b6925e1c355e7902200bc48b644a09545c0d4f6e..77dbfb3583479e765537639d485f44bd3a7fb6e8 100644
--- a/Mesh/Makefile
+++ b/Mesh/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.193 2008-01-19 22:06:03 geuzaine Exp $
+# $Id: Makefile,v 1.194 2008-01-19 23:04:13 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -94,9 +94,9 @@ Generator.o: Generator.cpp ../Common/Message.h ../Numeric/Numeric.h \
   ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h \
   ../Geo/GEntity.h ../Geo/SBoundingBox3d.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h meshGEdge.h meshGFace.h \
-  meshGRegion.h BackgroundMesh.h BoundaryLayer.h HighOrder.h
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h meshGEdge.h meshGFace.h meshGRegion.h \
+  BackgroundMesh.h BoundaryLayer.h HighOrder.h
 Field.o: Field.cpp ../Common/Message.h Field.h ../Post/PView.h \
   ../Common/SmoothData.h ../Numeric/Numeric.h ../Post/PViewData.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
@@ -121,10 +121,9 @@ meshGEdge.o: meshGEdge.cpp meshGEdge.h ../Geo/GEdge.h ../Geo/GEntity.h \
   ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h BackgroundMesh.h \
-  ../Common/Message.h
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h BackgroundMesh.h ../Numeric/Numeric.h \
+  ../Common/Message.h ../DataStr/List.h ../Common/Context.h
 meshGEdgeExtruded.o: meshGEdgeExtruded.cpp ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/MVertex.h \
@@ -135,29 +134,29 @@ meshGEdgeExtruded.o: meshGEdgeExtruded.cpp ../Geo/GModel.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Common/Message.h
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Numeric/Numeric.h \
+  ../Common/Message.h
 meshGFace.o: meshGFace.cpp meshGFace.h meshGFaceDelaunayInsertion.h \
   ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
   ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/Numeric.h ../Common/Context.h \
-  ../DataStr/List.h meshGFaceOptimize.h DivideAndConquer.h \
-  BackgroundMesh.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/MVertex.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Common/Message.h BDS.h ../Post/PView.h \
-  ../Common/SmoothData.h ../Post/PViewData.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h qualityMeasures.h Field.h ../Geo/Geo.h \
-  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SBoundingBox3d.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../Geo/SPoint2.h \
-  ../Geo/ExtrudeParams.h ../Post/OctreePost.h ../Common/Octree.h \
-  ../Common/OctreeInternals.h ../Common/OS.h
+  ../Geo/SPoint3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  meshGFaceOptimize.h DivideAndConquer.h BackgroundMesh.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/MVertex.h \
+  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
+  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Common/Context.h ../DataStr/List.h ../Common/Message.h \
+  ../Numeric/Numeric.h BDS.h ../Post/PView.h ../Common/SmoothData.h \
+  ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  qualityMeasures.h Field.h ../Geo/Geo.h ../Geo/gmshSurface.h \
+  ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h ../Geo/SPoint3.h \
+  ../Geo/SVector3.h ../Geo/SBoundingBox3d.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Geo/SPoint2.h ../Geo/ExtrudeParams.h \
+  ../Post/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h \
+  ../Common/OS.h
 meshGFaceTransfinite.o: meshGFaceTransfinite.cpp meshGFace.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/MVertex.h \
@@ -167,9 +166,9 @@ meshGFaceTransfinite.o: meshGFaceTransfinite.cpp meshGFace.h \
   ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Common/Message.h
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Common/Context.h ../DataStr/List.h \
+  ../Common/Message.h ../Numeric/Numeric.h
 meshGFaceExtruded.o: meshGFaceExtruded.cpp ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/MVertex.h \
@@ -180,9 +179,9 @@ meshGFaceExtruded.o: meshGFaceExtruded.cpp ../Geo/GModel.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Common/Message.h
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Numeric/Numeric.h \
+  ../Common/Context.h ../DataStr/List.h ../Common/Message.h
 meshGFaceDelaunayInsertion.o: meshGFaceDelaunayInsertion.cpp BDS.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -194,16 +193,14 @@ meshGFaceDelaunayInsertion.o: meshGFaceDelaunayInsertion.cpp BDS.h \
   ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
   BackgroundMesh.h meshGFaceDelaunayInsertion.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Context.h \
-  ../DataStr/List.h meshGFaceOptimize.h meshGFace.h ../Common/Message.h
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h meshGFaceOptimize.h meshGFace.h ../Common/Message.h
 meshGFaceOptimize.o: meshGFaceOptimize.cpp meshGFaceOptimize.h \
   ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
   ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/Numeric.h ../Common/Context.h \
-  ../DataStr/List.h meshGFaceDelaunayInsertion.h qualityMeasures.h \
-  ../Geo/GFace.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SPoint3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  meshGFaceDelaunayInsertion.h qualityMeasures.h ../Geo/GFace.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/MVertex.h ../Geo/GPoint.h ../Geo/SPoint2.h \
@@ -213,37 +210,35 @@ meshGRegion.o: meshGRegion.cpp meshGRegion.h \
   meshGRegionDelaunayInsertion.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
   ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  qualityMeasures.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Geo/MVertex.h ../Geo/GPoint.h ../Geo/SPoint2.h \
-  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
-  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/SBoundingBox3d.h ../Geo/gmshRegion.h ../Geo/Geo.h \
-  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SBoundingBox3d.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h qualityMeasures.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Geo/MVertex.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
+  ../Geo/gmshRegion.h ../Geo/Geo.h ../Geo/gmshSurface.h ../Geo/Pair.h \
+  ../Geo/Range.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \
+  ../Geo/SBoundingBox3d.h ../Numeric/Numeric.h ../DataStr/List.h \
   ../DataStr/Tree.h ../DataStr/avl.h ../Geo/SPoint2.h \
   ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Geo/GRegion.h BDS.h \
   ../Post/PView.h ../Post/PViewData.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h ../Common/Message.h
+  ../Post/ColorTable.h ../Common/Message.h ../Common/Context.h
 meshGRegionDelaunayInsertion.o: meshGRegionDelaunayInsertion.cpp \
   ../Common/OS.h BackgroundMesh.h meshGRegion.h meshGRegionLocalMeshMod.h \
   meshGRegionDelaunayInsertion.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
   ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  qualityMeasures.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Geo/MVertex.h ../Geo/GPoint.h ../Geo/SPoint2.h \
-  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
-  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/SBoundingBox3d.h ../Common/Message.h
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h qualityMeasures.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
+  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Geo/MVertex.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
+  ../Numeric/Numeric.h ../Common/Message.h
 meshGRegionTransfinite.o: meshGRegionTransfinite.cpp meshGFace.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -253,9 +248,9 @@ meshGRegionTransfinite.o: meshGRegionTransfinite.cpp meshGFace.h \
   ../Geo/SPoint2.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
   ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Common/Message.h
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Common/Context.h ../DataStr/List.h \
+  ../Common/Message.h
 meshGRegionExtruded.o: meshGRegionExtruded.cpp ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/MVertex.h \
@@ -266,9 +261,9 @@ meshGRegionExtruded.o: meshGRegionExtruded.cpp ../Geo/GModel.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  ../Geo/ExtrudeParams.h ../Common/SmoothData.h meshGFace.h meshGRegion.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Numeric/Numeric.h \
+  meshGFace.h meshGRegion.h ../Common/Context.h ../DataStr/List.h \
   ../Common/Message.h
 meshGRegionCarveHole.o: meshGRegionCarveHole.cpp ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
@@ -280,18 +275,15 @@ meshGRegionCarveHole.o: meshGRegionCarveHole.cpp ../Geo/GModel.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  ../Common/Message.h
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Message.h
 meshGRegionLocalMeshMod.o: meshGRegionLocalMeshMod.cpp \
   meshGRegionLocalMeshMod.h meshGRegionDelaunayInsertion.h \
   ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
   ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/Numeric.h ../Common/Context.h \
-  ../DataStr/List.h qualityMeasures.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Common/Message.h
+  ../Geo/SPoint3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  qualityMeasures.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Common/Message.h ../Numeric/Numeric.h
 DivideAndConquer.o: DivideAndConquer.cpp ../Common/Message.h \
   ../Numeric/Numeric.h DivideAndConquer.h ../DataStr/Malloc.h
 BackgroundMesh.o: BackgroundMesh.cpp ../Common/Message.h BackgroundMesh.h \
@@ -321,9 +313,8 @@ qualityMeasures.o: qualityMeasures.cpp qualityMeasures.h BDS.h \
   ../Post/PView.h ../Common/SmoothData.h ../Numeric/Numeric.h \
   ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
   ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Context.h \
-  ../DataStr/List.h
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h
 BoundaryLayer.o: BoundaryLayer.cpp ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/MVertex.h \
@@ -334,9 +325,8 @@ BoundaryLayer.o: BoundaryLayer.cpp ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  BoundaryLayer.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h BoundaryLayer.h \
+  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Numeric/Numeric.h \
   meshGEdge.h meshGFace.h ../Common/Message.h
 BDS.o: BDS.cpp ../Numeric/Numeric.h ../Common/GmshMatrix.h BDS.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
@@ -358,7 +348,7 @@ HighOrder.o: HighOrder.cpp HighOrder.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h meshGFaceOptimize.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h meshGFaceDelaunayInsertion.h \
-  ../Common/Message.h ../Common/OS.h
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h meshGFaceDelaunayInsertion.h ../Common/Message.h \
+  ../Common/OS.h ../Numeric/Numeric.h ../Common/Context.h \
+  ../DataStr/List.h
diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp
index 86d6688f8c2e05bcbd8d2f02f148786b6d92827b..ce8ef9ae5563ba621aef80ca2bb8cf4a29c4dfd1 100644
--- a/Mesh/meshGEdge.cpp
+++ b/Mesh/meshGEdge.cpp
@@ -1,4 +1,4 @@
-// $Id: meshGEdge.cpp,v 1.49 2008-01-19 22:06:03 geuzaine Exp $
+// $Id: meshGEdge.cpp,v 1.50 2008-01-19 23:04:13 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -25,6 +25,10 @@
 #include "BackgroundMesh.h"
 #include "Numeric.h"
 #include "Message.h"
+#include "List.h"
+#include "Context.h"
+
+extern Context_T CTX;
 
 typedef struct{
   int Num;
diff --git a/Mesh/meshGFaceOptimize.h b/Mesh/meshGFaceOptimize.h
index e3f0d8e404178268018f45735afd0383f982380b..f42588209968afd92c482094747a309305f36174 100644
--- a/Mesh/meshGFaceOptimize.h
+++ b/Mesh/meshGFaceOptimize.h
@@ -19,11 +19,13 @@
 // USA.
 // 
 // Please report all bugs and problems to <gmsh@geuz.org>.
+
+#include <map>
+#include <vector>
 #include "MElement.h"
 #include "MEdge.h"
 #include "meshGFaceDelaunayInsertion.h"
-#include <map>
-#include <vector>
+
 class GFace;
 class MVertex;
 typedef std::map<MVertex*,std::vector<MTriangle*> > v2t_cont ;
diff --git a/Mesh/meshGFaceTransfinite.cpp b/Mesh/meshGFaceTransfinite.cpp
index 8b9a43e30e01ecc073aaf20f972837e8c84259bf..7138cbd09732798ca0f60adc9275ee1897dd6859 100644
--- a/Mesh/meshGFaceTransfinite.cpp
+++ b/Mesh/meshGFaceTransfinite.cpp
@@ -1,4 +1,4 @@
-// $Id: meshGFaceTransfinite.cpp,v 1.22 2007-11-27 16:45:27 geuzaine Exp $
+// $Id: meshGFaceTransfinite.cpp,v 1.23 2008-01-19 23:04:13 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -28,6 +28,7 @@
 #include "MElement.h"
 #include "Context.h"
 #include "Message.h"
+#include "Numeric.h"
 
 extern Context_T CTX;
 
diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp
index 6cd56c4c20ec6ddbc0f2d9dc518ec47688148359..8b261358bb788f13e0c0fab32c67b0e7adcbf45b 100644
--- a/Mesh/meshGRegion.cpp
+++ b/Mesh/meshGRegion.cpp
@@ -1,4 +1,4 @@
-// $Id: meshGRegion.cpp,v 1.38 2008-01-14 21:29:14 remacle Exp $
+// $Id: meshGRegion.cpp,v 1.39 2008-01-19 23:04:13 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -19,6 +19,7 @@
 // 
 // Please report all bugs and problems to <gmsh@geuz.org>.
 
+#include <vector>
 #include "meshGRegion.h"
 #include "meshGRegionDelaunayInsertion.h"
 #include "GModel.h"
@@ -28,7 +29,9 @@
 #include "gmshRegion.h"
 #include "BDS.h"
 #include "Message.h"
-#include <vector>
+#include "Context.h"
+
+extern Context_T CTX;
 
 void getAllBoundingVertices(GRegion *gr, std::set<MVertex*> &allBoundingVertices)
 {
diff --git a/Mesh/meshGRegionLocalMeshMod.cpp b/Mesh/meshGRegionLocalMeshMod.cpp
index a3d4a919432c8c7f46c4f11ddf839dd087f25d25..a23d09f38ebd319de468103f55b7ba3f05af1332 100644
--- a/Mesh/meshGRegionLocalMeshMod.cpp
+++ b/Mesh/meshGRegionLocalMeshMod.cpp
@@ -2,6 +2,7 @@
 #include "GEntity.h"
 #include "GRegion.h"
 #include "Message.h"
+#include "Numeric.h"
 
 static int edges[6][2] =    {{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}};
 static int efaces[6][2] =   {{0,2},{0,1},{1,2},{0,3},{2,3},{1,3}};