diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp
index a86138812cd3170bd24612af877c98afebd21a34..e10d2864b9de9fab2dbe94af7530af44847f3019 100644
--- a/Geo/MElement.cpp
+++ b/Geo/MElement.cpp
@@ -29,6 +29,21 @@ int MElement::_globalNum = 0;
 double MElement::_isInsideTolerance = 1.e-6;
 double MElementLessThanLexicographic::tolerance = 1.e-6;
 
+MElement::MElement(int num, int part) : _visible(1) 
+{
+#pragma omp critical
+  {
+    if(num){
+      _num = num;
+      _globalNum = std::max(_globalNum, _num);
+    }
+    else{
+      _num = ++_globalNum;
+    }
+    _partition = (short)part; 
+  }
+}
+
 void MElement::_getEdgeRep(MVertex *v0, MVertex *v1, 
                            double *x, double *y, double *z, SVector3 *n, 
                            int faceIndex)
diff --git a/Geo/MElement.h b/Geo/MElement.h
index 4f90fc0f76e76fe75dbf714e070d8d09b166d2e9..d768db005070d8cc6917e97d46075076d1e53d54 100644
--- a/Geo/MElement.h
+++ b/Geo/MElement.h
@@ -42,17 +42,7 @@ class MElement
   void _getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2, 
                    double *x, double *y, double *z, SVector3 *n);
  public :
-  MElement(int num=0, int part=0) : _visible(1) 
-  {
-    if(num){
-      _num = num;
-      _globalNum = std::max(_globalNum, _num);
-    }
-    else{
-      _num = ++_globalNum;
-    }
-    _partition = (short)part; 
-  }
+  MElement(int num=0, int part=0);
   virtual ~MElement(){}
 
   // reset the global node number
diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp
index d7cdd0485900265eb4df44ced3a4bda707667db8..7c7c5dab2e6e1713652f139eda9eb29ecf8e2932 100644
--- a/Geo/MVertex.cpp
+++ b/Geo/MVertex.cpp
@@ -26,6 +26,31 @@ bool MVertexLessThanLexicographic::operator()(const MVertex *v1, const MVertex *
   return false;
 }
 
+MVertex::MVertex(double x, double y, double z, GEntity *ge, int num)
+  : _visible(1), _order(1), _x(x), _y(y), _z(z), _ge(ge)
+{
+#pragma omp critical
+  {
+    if(num){
+      _num = num;
+      _globalNum = std::max(_globalNum, _num);
+    }
+    else{
+      _num = ++_globalNum;
+    }
+    _index = num;
+  }
+}
+
+void MVertex::setNum(int num)
+{ 
+#pragma omp critical
+  {
+    _num = num; 
+    _globalNum = std::max(_globalNum, _num);
+  }
+}
+
 void MVertex::writeMSH(FILE *fp, bool binary, bool saveParametric, double scalingFactor)
 {
   if(_index < 0) return; // negative index vertices are never saved
diff --git a/Geo/MVertex.h b/Geo/MVertex.h
index d755cfb9a5929388796f54e29a1c185049a60872..1cf422768fa36410ee27d2c445d0423456eed1cb 100644
--- a/Geo/MVertex.h
+++ b/Geo/MVertex.h
@@ -43,18 +43,7 @@ class MVertex{
   GEntity *_ge;
 
  public :
-  MVertex(double x, double y, double z, GEntity *ge=0, int num=0) 
-    : _visible(1), _order(1), _x(x), _y(y), _z(z), _ge(ge)
-  {
-    if(num){
-      _num = num;
-      _globalNum = std::max(_globalNum, _num);
-    }
-    else{
-      _num = ++_globalNum;
-    }
-    _index = num;
-  }
+  MVertex(double x, double y, double z, GEntity *ge=0, int num=0);
   virtual ~MVertex(){}
 
   // get/reset the global node number
@@ -84,11 +73,7 @@ class MVertex{
 
   // get/set the number
   inline int getNum() const { return _num; }
-  inline void setNum(int num) 
-  { 
-    _num = num; 
-    _globalNum = std::max(_globalNum, _num);
-  }
+  void setNum(int num);
 
   // get/set the index
   inline int getIndex() const { return _index; }