diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp
index 5f676bc2effd345fd7346dd589fe8a264e21f56a..2240c34251b8a9ce7cc2b14ecb66dab4b14d8bea 100644
--- a/Mesh/meshGFace.cpp
+++ b/Mesh/meshGFace.cpp
@@ -91,9 +91,11 @@ static void remeshUnrecoveredEdges(std::map<MVertex*, BDS_Point*> &recoverMapInv
     for(int i = 0; i < N; i++){
       MVertex *v1 = itr->ge->lines[i]->getVertex(0);
       MVertex *v2 = itr->ge->lines[i]->getVertex(1);
-      if(recoverMapInv.count(v1) && recoverMapInv.count(v2)){
-        BDS_Point *pp1 = recoverMapInv[v1];
-        BDS_Point *pp2 = recoverMapInv[v2];
+      std::map<MVertex*, BDS_Point*>::iterator itp1 = recoverMapInv.find(v1);
+      std::map<MVertex*, BDS_Point*>::iterator itp2 = recoverMapInv.find(v2);
+      if(itp1 != recoverMapInv.end() && itp2 != recoverMapInv.end()){
+        BDS_Point *pp1 = itp1->second;
+        BDS_Point *pp2 = itp2->second;
         if((pp1->iD == p1 && pp2->iD == p2) || (pp1->iD == p2 && pp2->iD == p1)){
           double t1;
           double lc1 = -1;
@@ -189,36 +191,44 @@ static bool recover_medge(BDS_Mesh *m, GEdge *ge,
   for(unsigned int i = 0; i < ge->lines.size(); i++){
     MVertex *vstart = ge->lines[i]->getVertex(0);
     MVertex *vend = ge->lines[i]->getVertex(1);
-    BDS_Point *pstart = recoverMapInv[vstart];
-    BDS_Point *pend = recoverMapInv[vend];
-    if(pass_ == 1) 
-      e2r->insert(EdgeToRecover(pstart->iD, pend->iD, ge));
-    else{
-      BDS_Edge *e = m->recover_edge(pstart->iD, pend->iD, e2r, not_recovered);
-      if(e) e->g = g;
-      // else {
-      //   Msg::Error("Unable to recover an edge %g %g && %g %g (%d/%d)",
-      //              vstart->x(), vstart->y(), vend->x(), vend->y(), i, 
-      //              ge->mesh_vertices.size());
-      //   return false;
-      // }
+    std::map<MVertex*, BDS_Point*>::iterator itpstart = recoverMapInv.find(vstart);
+    std::map<MVertex*, BDS_Point*>::iterator itpend = recoverMapInv.find(vend);
+    if(itpstart != recoverMapInv.end() && itpend != recoverMapInv.end()){
+      BDS_Point *pstart = itpstart->second;
+      BDS_Point *pend = itpend->second;
+      if(pass_ == 1) 
+        e2r->insert(EdgeToRecover(pstart->iD, pend->iD, ge));
+      else{
+        BDS_Edge *e = m->recover_edge(pstart->iD, pend->iD, e2r, not_recovered);
+        if(e) e->g = g;
+        // else {
+        //   Msg::Error("Unable to recover an edge %g %g && %g %g (%d/%d)",
+        //              vstart->x(), vstart->y(), vend->x(), vend->y(), i, 
+        //              ge->mesh_vertices.size());
+        //   return false;
+        // }
+      }
     }
   }
 
   if(pass_ == 2 && ge->getBeginVertex()){
     MVertex *vstart = *(ge->getBeginVertex()->mesh_vertices.begin());
     MVertex *vend = *(ge->getEndVertex()->mesh_vertices.begin());    
-    BDS_Point *pstart = recoverMapInv[vstart];
-    BDS_Point *pend = recoverMapInv[vend];
-    if(!pstart->g){
-      m->add_geom(pstart->iD, 0);
-      BDS_GeomEntity *g0 = m->get_geom(pstart->iD, 0);
-      pstart->g = g0;
-    }
-    if(!pend->g){
-      m->add_geom(pend->iD, 0);
-      BDS_GeomEntity *g0 = m->get_geom(pend->iD, 0);
-      pend->g = g0;
+    std::map<MVertex*, BDS_Point*>::iterator itpstart = recoverMapInv.find(vstart);
+    std::map<MVertex*, BDS_Point*>::iterator itpend = recoverMapInv.find(vend);
+    if(itpstart != recoverMapInv.end() && itpend != recoverMapInv.end()){
+      BDS_Point *pstart = itpstart->second;
+      BDS_Point *pend = itpend->second;
+      if(!pstart->g){
+        m->add_geom(pstart->iD, 0);
+        BDS_GeomEntity *g0 = m->get_geom(pstart->iD, 0);
+        pstart->g = g0;
+      }
+      if(!pend->g){
+        m->add_geom(pend->iD, 0);
+        BDS_GeomEntity *g0 = m->get_geom(pend->iD, 0);
+        pend->g = g0;
+      }
     }
   }
 
@@ -509,8 +519,9 @@ static bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER,
                edgesToRecover.size());
     for(int i = 0; i < doc.numPoints; i++){
       BDS_Point *pp = (BDS_Point*)doc.points[i].data;
-      if(recoverMap.count(pp)){
-        MVertex *here = recoverMap[pp];
+      std::map<BDS_Point*, MVertex*>::iterator itv = recoverMap.find(pp);
+      if(itv != recoverMap.end()){
+        MVertex *here = itv->second;
         GEntity *ge = here->onWhat();
         if(ge->dim() == 0){
           pp->lcBGM() = BGM_MeshSize(ge, 0, 0, here->x(), here->y(), here->z());
diff --git a/Mesh/meshGFaceBDS.cpp b/Mesh/meshGFaceBDS.cpp
index 6ca2e2057dee44c81e8a88761c40302b2cb73502..78a147473dae8f2ca7cb954f01c6c1e6720023ba 100644
--- a/Mesh/meshGFaceBDS.cpp
+++ b/Mesh/meshGFaceBDS.cpp
@@ -677,8 +677,9 @@ void gmshRefineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
     std::list<GVertex*>::iterator itvx = emb_vertx.begin();
     while(itvx != emb_vertx.end()){
       MVertex *v = *((*itvx)->mesh_vertices.begin());
-      if(recoverMapInv->count(v)){
-        BDS_Point *p = (*recoverMapInv)[v];
+      std::map<MVertex*, BDS_Point*>::iterator itp = recoverMapInv->find(v);
+      if(itp != recoverMapInv->end()){
+        BDS_Point *p = itp->second;
         m.add_geom(-1, 2);
         p->g = m.get_geom(-1, 2);
         p->lc() = (*itvx)->prescribedMeshSizeAtVertex();
@@ -720,9 +721,9 @@ void gmshRefineMeshBDS(GFace *gf, BDS_Mesh &m, const int NIT,
 
   while (1){
     // we count the number of local mesh modifs.
-    int nb_split =0;
-    int nb_smooth  = 0 ;
-    int nb_collaps =0;
+    int nb_split = 0;
+    int nb_smooth = 0;
+    int nb_collaps = 0;
     int nb_swap = 0;
 
     // split long edges