diff --git a/Box/Main.cpp b/Box/Main.cpp
index adc8da5d8726dc18c8be673f18dd5fd922165380..f44140d87d32dd04e0b908f78e05e337e69f07c9 100644
--- a/Box/Main.cpp
+++ b/Box/Main.cpp
@@ -1,4 +1,4 @@
-// $Id: Main.cpp,v 1.63 2006-08-10 15:55:23 geuzaine Exp $
+// $Id: Main.cpp,v 1.64 2006-08-12 17:44:24 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -77,6 +77,8 @@ int GMSHBOX(int argc, char *argv[])
 {
   ParUtil::Instance()->init(argc, argv);
 
+  GMODEL = new gmshModel;
+
   InitSymbols();
 
   Init_Mesh0(&M);
diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index 58fe37f4ab563922f4ce2906097f1873166fa114..15dad82cbeeacab5871f4876e3e28630ce776f54 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -1,4 +1,4 @@
-// $Id: CommandLine.cpp,v 1.75 2006-08-12 16:44:31 geuzaine Exp $
+// $Id: CommandLine.cpp,v 1.76 2006-08-12 17:44:24 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -300,7 +300,7 @@ void Get_Options(int argc, char *argv[])
             WriteView(*(Post_View **) List_Pointer(CTX.post.list, j),
                       argv[i + 1], 1, j ? 1 : 0);
 	  // convert any mesh to the latest format
-	  if(GMODEL && GMODEL->numVertex()){
+	  if(GMODEL->numVertex()){
 	    CTX.mesh.msh_file_version = 2.0;
 	    CreateOutputFile(argv[i + 1], FORMAT_MSH);
 	  }
diff --git a/Common/Visibility.h b/Common/Visibility.h
index 0cb2d4372aa5203662ad4c7ac31cc8051608d955..c72a26474488f55f2fa5444d414eb9458f8fb1e3 100644
--- a/Common/Visibility.h
+++ b/Common/Visibility.h
@@ -126,7 +126,7 @@ class VisibilityManager {
   char getVisibility(int n){ return _entities[n]->getVisibility(); }
 
   // set the visibility information for the nth entity in the manager
-  void setVisibility(char n, int val, bool recursive=false)
+  void setVisibility(int n, char val, bool recursive=false)
   { 
     _entities[n]->setVisibility(val, recursive);
   }
diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp
index 6c7212178740a1e0e92bf29267b27bee141439ca..1d2467942935ee253ec37601ef35481023f3467b 100644
--- a/Fltk/Main.cpp
+++ b/Fltk/Main.cpp
@@ -1,4 +1,4 @@
-// $Id: Main.cpp,v 1.96 2006-08-10 15:55:23 geuzaine Exp $
+// $Id: Main.cpp,v 1.97 2006-08-12 17:44:24 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -38,7 +38,7 @@
 #include "Numeric.h"
 #include "Solvers.h"
 #include "PluginManager.h"
-#include "GModel.h"
+#include "gmshModel.h"
 
 Context_T CTX;
 Mesh M, *THEM = &M;
@@ -67,6 +67,9 @@ int main(int argc, char *argv[])
     strcat(cmdline, " ");
   }
 
+  // Create a new gmsh model
+  GMODEL = new gmshModel;
+
   // Initialize the symbol tree that will hold variable names
   
   InitSymbols();
diff --git a/Fltk/Makefile b/Fltk/Makefile
index 3fb979417b523ede168ac7d6451b34d51f1b0ce4..53fd7e47fd4071e48dec07dc784941e58677d195 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.97 2006-08-12 16:44:31 geuzaine Exp $
+# $Id: Makefile,v 1.98 2006-08-12 17:44:24 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -81,15 +81,15 @@ Main.o: Main.cpp GUI.h Opengl_Window.h ../Mesh/Mesh.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Context.h \
   ../Common/Options.h ../Parser/Parser.h ../Parser/OpenFile.h \
   ../Common/CommandLine.h Solvers.h ../Plugin/PluginManager.h \
-  ../Plugin/Plugin.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/MVertex.h ../Geo/GPoint.h \
-  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
-  ../Geo/MVertex.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
-  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/MElement.h \
-  ../Geo/SBoundingBox3d.h
+  ../Plugin/Plugin.h ../Geo/gmshModel.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/MVertex.h ../Geo/GPoint.h ../Geo/GEdge.h ../Geo/GEntity.h \
+  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h ../Geo/GFace.h \
+  ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/MElement.h ../Geo/SBoundingBox3d.h
 # 1 "/Users/geuzaine/.gmsh/Fltk//"
 Message.o: Message.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
diff --git a/Geo/GModel.h b/Geo/GModel.h
index 9639e0a757a6be7b6dacf7f1ebb83dbd2e354a63..8a348fc08d1f9799e9e2b18e5033071258a64a1e 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -27,6 +27,8 @@ class GModel
   GModel(const std::string &name) : modelName(name) {}
   virtual ~GModel() {}
 
+  virtual void import(){}
+
   typedef std::set<GRegion*, GEntityLessThan>::iterator riter;
   typedef std::set<GFace*, GEntityLessThan>::iterator fiter;
   typedef std::set<GEdge*, GEntityLessThan>::iterator eiter;
diff --git a/Geo/Makefile b/Geo/Makefile
index b85cab8d7060418f94237072bad8c557c774ab47..24d337c6ea2d6c3c7e2c60c18057c1a179ea9de6 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.86 2006-08-12 16:44:31 geuzaine Exp $
+# $Id: Makefile,v 1.87 2006-08-12 17:44:24 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -174,9 +174,9 @@ gmshModel.o: gmshModel.cpp gmshModel.h GModel.h GVertex.h GEntity.h \
   ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
   ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
   ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h Geo.h ../Parser/OpenFile.h ../DataStr/Tools.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Common/Message.h gmshVertex.h \
-  gmshFace.h gmshEdge.h gmshRegion.h
+  ../Mesh/Matrix.h Geo.h ../DataStr/Tools.h ../DataStr/List.h \
+  ../DataStr/Tree.h ../Common/Message.h gmshVertex.h gmshFace.h \
+  gmshEdge.h gmshRegion.h
 # 1 "/Users/geuzaine/.gmsh/Geo//"
 gmshEdge.o: gmshEdge.cpp gmshModel.h GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h MVertex.h ../Common/GmshDefines.h GPoint.h \
diff --git a/Geo/gmshModel.cpp b/Geo/gmshModel.cpp
index b471257f7a5cbf883961777fbfe389e78ae0f3c1..dda2f161d04c5c474d8b84442b8bf52c8f73e106 100644
--- a/Geo/gmshModel.cpp
+++ b/Geo/gmshModel.cpp
@@ -1,11 +1,6 @@
 #include "gmshModel.h"
 #include "Mesh.h"
 #include "Geo.h"
-#include "GPoint.h"
-#include "SPoint2.h"
-#include "SPoint3.h"
-#include "SBoundingBox3d.h"
-#include "OpenFile.h"
 #include "Tools.h"
 #include "Message.h"
 #include "gmshVertex.h"
@@ -18,17 +13,10 @@ extern Mesh *THEM;
 gmshModel::gmshModel()
   : GModel("noname")
 {
-  convertFromUglyOldDataStructuresgmshModel();
+  import();
 }
 
-gmshModel::gmshModel(char *geofile)
-  : GModel(geofile)
-{
-  OpenProblem(geofile);
-  convertFromUglyOldDataStructuresgmshModel();
-}
-
-void gmshModel::convertFromUglyOldDataStructuresgmshModel()
+void gmshModel::import()
 {
   std::set<Vertex*> points;
 
@@ -38,23 +26,25 @@ void gmshModel::convertFromUglyOldDataStructuresgmshModel()
       Curve *c;
       List_Read(curves, i, &c);
       if(c->Num >= 0 && c->beg && c->end){
-	if(points.find(c->beg) == points.end()){
+	if(!vertexByTag(c->beg->Num) && points.find(c->beg) == points.end()){
 	  points.insert(c->beg);
 	  gmshVertex *v = new gmshVertex(this, c->beg);
 	  v->setVisibility(c->beg->Visible);
 	  add(v);
 	}
-	if(points.find(c->end) == points.end()){
+	if(!vertexByTag(c->end->Num) && points.find(c->end) == points.end()){
 	  points.insert(c->end);
 	  gmshVertex *v = new gmshVertex(this, c->end);
 	  v->setVisibility(c->beg->Visible);
 	  add(v);
 	}
-	gmshEdge *e = new gmshEdge(this, c,
-				   vertexByTag(c->beg->Num),
-				   vertexByTag(c->end->Num));
-	e->setVisibility(c->Visible);
-	add(e);
+	if(!edgeByTag(c->Num)){
+	  gmshEdge *e = new gmshEdge(this, c,
+				     vertexByTag(c->beg->Num),
+				     vertexByTag(c->end->Num));
+	  e->setVisibility(c->Visible);
+	  add(e);
+	}
       }
     }
     List_Delete(curves);
@@ -64,9 +54,11 @@ void gmshModel::convertFromUglyOldDataStructuresgmshModel()
     for(int i = 0; i < List_Nbr(surfaces); i++){
       Surface *s;
       List_Read(surfaces, i, &s);
-      gmshFace *f = new gmshFace(this, s);
-      f->setVisibility(s->Visible);
-      add(f);
+      if(!faceByTag(s->Num)){
+	gmshFace *f = new gmshFace(this, s);
+	f->setVisibility(s->Visible);
+	add(f);
+      }
     }
     List_Delete(surfaces);
   } 
@@ -75,9 +67,11 @@ void gmshModel::convertFromUglyOldDataStructuresgmshModel()
     for(int i = 0; i < List_Nbr(volumes); i++){
       Volume *v;
       List_Read(volumes, i, &v);
-      gmshRegion *r = new gmshRegion(this, v);
-      r->setVisibility(v->Visible);
-      add(r);
+      if(!regionByTag(v->Num)){
+	gmshRegion *r = new gmshRegion(this, v);
+	r->setVisibility(v->Visible);
+	add(r);
+      }
     }
     List_Delete(volumes);
   }
@@ -94,7 +88,9 @@ void gmshModel::convertFromUglyOldDataStructuresgmshModel()
       case MSH_PHYSICAL_SURFACE: ge = faceByTag(num); break;
       case MSH_PHYSICAL_VOLUME:  ge = regionByTag(num); break;
       }
-      if(ge) ge->physicals.push_back(p->Num);
+      if(ge && std::find(ge->physicals.begin(), ge->physicals.end(), p->Num) == 
+	 ge->physicals.end())
+	ge->physicals.push_back(p->Num);
     }
   }
   
@@ -105,7 +101,3 @@ void gmshModel::convertFromUglyOldDataStructuresgmshModel()
   Msg(DEBUG, "%d Regions", regions.size());
 }
 
-GModel *createGmshModel(char *f)
-{
-  return new gmshModel(f);
-}
diff --git a/Geo/gmshModel.h b/Geo/gmshModel.h
index c6a18e027dfd79127244837100235541fbf91fd2..1386f34e6448248147d21f12d82a23ecec62969a 100644
--- a/Geo/gmshModel.h
+++ b/Geo/gmshModel.h
@@ -4,12 +4,12 @@
 #include "GModel.h"
 
 class gmshModel : public GModel {
- private:
-  void convertFromUglyOldDataStructuresgmshModel(); 
  public:
-  gmshModel(char *geofile); 
   gmshModel(); 
   virtual ~gmshModel() {};
+
+  // import data from the old Gmsh database ("THEM")
+  virtual void import();
 };
 
 #endif
diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp
index 70acadc0eea4ed797183c5d5ca60e834981cb5ca..a03dc56a9d934426d1046e59e65f57ca4f91bf57 100644
--- a/Graphics/Geom.cpp
+++ b/Graphics/Geom.cpp
@@ -1,4 +1,4 @@
-// $Id: Geom.cpp,v 1.105 2006-08-12 16:16:30 geuzaine Exp $
+// $Id: Geom.cpp,v 1.106 2006-08-12 17:44:24 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -243,8 +243,6 @@ void drawGeoRegion(GRegion *v)
 
 void Draw_Geom()
 {
-  if(!GMODEL) return;
-
   glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
   
   for(int i = 0; i < 6; i++)
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 1c35f78eed9044c143fa4625ab19cb234d826642..3b293abad3babe2daffaa29d8676347e7f4472ef 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.158 2006-08-12 16:16:30 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.159 2006-08-12 17:44:25 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -206,7 +206,7 @@ public :
 
 void Draw_Mesh()
 {
-  if(!GMODEL || !CTX.mesh.draw) return;
+  if(!CTX.mesh.draw) return;
   
   glPointSize(CTX.mesh.point_size);
   gl2psPointSize(CTX.mesh.point_size * CTX.print.eps_point_size_factor);
diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp
index ff8f86a6ed41e9340f78ac5378f4831392e6a2e8..7231ecee198ec68ac4a8e137cb08c08046ee02f4 100644
--- a/Mesh/Generator.cpp
+++ b/Mesh/Generator.cpp
@@ -1,4 +1,4 @@
-// $Id: Generator.cpp,v 1.92 2006-08-12 16:44:31 geuzaine Exp $
+// $Id: Generator.cpp,v 1.93 2006-08-12 17:44:25 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -69,69 +69,67 @@ void GetStatistics(double stat[50], double quality[3][100])
 {
   for(int i = 0; i < 50; i++) stat[i] = 0.;
 
-  if(GMODEL){
-    stat[0] = GMODEL->numVertex();
-    stat[1] = GMODEL->numEdge();
-    stat[2] = GMODEL->numFace();
-    stat[3] = GMODEL->numRegion();
-
-    std::map<int, std::vector<GEntity*> > physicals[4];
-    GMODEL->getPhysicalGroups(physicals);
-    stat[45] = physicals[0].size() + physicals[1].size() + 
-      physicals[2].size() + physicals[3].size();
-
-    for(GModel::eiter it = GMODEL->firstEdge(); it != GMODEL->lastEdge(); ++it)
-      stat[4] += (*it)->mesh_vertices.size();
-
-    for(GModel::fiter it = GMODEL->firstFace(); it != GMODEL->lastFace(); ++it){
-      stat[5] += (*it)->mesh_vertices.size();
-      stat[7] += (*it)->triangles.size();
-      stat[8] += (*it)->quadrangles.size();
-    }
-
+  stat[0] = GMODEL->numVertex();
+  stat[1] = GMODEL->numEdge();
+  stat[2] = GMODEL->numFace();
+  stat[3] = GMODEL->numRegion();
+  
+  std::map<int, std::vector<GEntity*> > physicals[4];
+  GMODEL->getPhysicalGroups(physicals);
+  stat[45] = physicals[0].size() + physicals[1].size() + 
+    physicals[2].size() + physicals[3].size();
+  
+  for(GModel::eiter it = GMODEL->firstEdge(); it != GMODEL->lastEdge(); ++it)
+    stat[4] += (*it)->mesh_vertices.size();
+  
+  for(GModel::fiter it = GMODEL->firstFace(); it != GMODEL->lastFace(); ++it){
+    stat[5] += (*it)->mesh_vertices.size();
+    stat[7] += (*it)->triangles.size();
+    stat[8] += (*it)->quadrangles.size();
+  }
+  
+  for(GModel::riter it = GMODEL->firstRegion(); it != GMODEL->lastRegion(); ++it){
+    stat[6] += (*it)->mesh_vertices.size();
+    stat[9] += (*it)->tetrahedra.size();
+    stat[10] += (*it)->hexahedra.size();
+    stat[11] += (*it)->prisms.size();
+    stat[12] += (*it)->pyramids.size();
+  }
+  
+  stat[13] = CTX.mesh_timer[0];
+  stat[14] = CTX.mesh_timer[1];
+  stat[15] = CTX.mesh_timer[2];
+  
+  // FIXME:
+  //stat[16] = numOrder2Vertices; 
+  
+  if(quality){
+    for(int i = 0; i < 3; i++)
+      for(int j = 0; j < 100; j++)
+	quality[i][j] = 0.;
+    double gamma=0., gammaMin=1., gammaMax=0.;
+    double eta=0., etaMin=1., etaMax=0.;
+    double rho=0., rhoMin=1., rhoMax=0.;
     for(GModel::riter it = GMODEL->firstRegion(); it != GMODEL->lastRegion(); ++it){
-      stat[6] += (*it)->mesh_vertices.size();
-      stat[9] += (*it)->tetrahedra.size();
-      stat[10] += (*it)->hexahedra.size();
-      stat[11] += (*it)->prisms.size();
-      stat[12] += (*it)->pyramids.size();
-    }
-
-    stat[13] = CTX.mesh_timer[0];
-    stat[14] = CTX.mesh_timer[1];
-    stat[15] = CTX.mesh_timer[2];
-
-    // FIXME:
-    //stat[16] = numOrder2Vertices; 
-
-    if(quality){
-      for(int i = 0; i < 3; i++)
-	for(int j = 0; j < 100; j++)
-	  quality[i][j] = 0.;
-      double gamma=0., gammaMin=1., gammaMax=0.;
-      double eta=0., etaMin=1., etaMax=0.;
-      double rho=0., rhoMin=1., rhoMax=0.;
-      for(GModel::riter it = GMODEL->firstRegion(); it != GMODEL->lastRegion(); ++it){
-	GetQualityMeasure((*it)->tetrahedra, gamma, gammaMin, gammaMax,
-			  eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
-	GetQualityMeasure((*it)->hexahedra, gamma, gammaMin, gammaMax,
-			  eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
-	GetQualityMeasure((*it)->prisms, gamma, gammaMin, gammaMax,
-			  eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
-	GetQualityMeasure((*it)->pyramids, gamma, gammaMin, gammaMax,
-			  eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
-      }
-      double N = stat[9] + stat[10] + stat[11] + stat[12];
-      stat[17] = N ? gamma / N : 0.;
-      stat[18] = gammaMin;
-      stat[19] = gammaMax;
-      stat[20] = N ? eta / N : 0.;
-      stat[21] = etaMin;
-      stat[22] = etaMax;
-      stat[23] = N ? rho / N : 0;
-      stat[24] = rhoMin;
-      stat[25] = rhoMax;
+      GetQualityMeasure((*it)->tetrahedra, gamma, gammaMin, gammaMax,
+			eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
+      GetQualityMeasure((*it)->hexahedra, gamma, gammaMin, gammaMax,
+			eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
+      GetQualityMeasure((*it)->prisms, gamma, gammaMin, gammaMax,
+			eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
+      GetQualityMeasure((*it)->pyramids, gamma, gammaMin, gammaMax,
+			eta, etaMin, etaMax, rho, rhoMin, rhoMax, quality);
     }
+    double N = stat[9] + stat[10] + stat[11] + stat[12];
+    stat[17] = N ? gamma / N : 0.;
+    stat[18] = gammaMin;
+    stat[19] = gammaMax;
+    stat[20] = N ? eta / N : 0.;
+    stat[21] = etaMin;
+    stat[22] = etaMax;
+    stat[23] = N ? rho / N : 0;
+    stat[24] = rhoMin;
+    stat[25] = rhoMax;
   }
 
   stat[26] = List_Nbr(CTX.post.list);
diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp
index 740987bb530ea2ba80ce691e6fbc1bfd29fe3ee2..d9c3c52f72a8f210682c865721c794e58793f0a5 100644
--- a/Parser/OpenFile.cpp
+++ b/Parser/OpenFile.cpp
@@ -1,4 +1,4 @@
-// $Id: OpenFile.cpp,v 1.106 2006-08-12 16:16:36 geuzaine Exp $
+// $Id: OpenFile.cpp,v 1.107 2006-08-12 17:44:25 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -142,10 +142,9 @@ void SetBoundingBox(void)
 
   SBoundingBox3d bb;
 
-  if(GMODEL)
-    bb = GMODEL->getBounds();
+  bb = GMODEL->getBounds();
 
-  if(bb.empty() && GMODEL)
+  if(bb.empty())
     bb = GMODEL->recomputeBounds();
   
   if(bb.empty() && List_Nbr(CTX.post.list)) {
@@ -208,8 +207,7 @@ int ParseFile(char *f, int close, int warn_if_missing)
   if(close)
     fclose(yyin);
 
-  if(GMODEL) delete GMODEL;
-  GMODEL = new gmshModel;
+  GMODEL->import();
 
   strncpy(yyname, yyname_old, 255);
   yyin = yyin_old;
@@ -289,11 +287,9 @@ int MergeProblem(char *name, int warn_if_missing)
 
   int status = 0;
   if(!strcmp(ext, ".stl") || !strcmp(ext, ".STL")){
-    if(!GMODEL) GMODEL = new gmshModel;
     status = GMODEL->readSTL(name, CTX.mesh.stl_distance_tol);
   }
   else if(!strcmp(ext, ".mesh")){
-    if(!GMODEL) GMODEL = new gmshModel;
     status = GMODEL->readMESH(name);
   }
 #if defined(HAVE_FLTK)
@@ -327,7 +323,6 @@ int MergeProblem(char *name, int warn_if_missing)
     if(!strncmp(tmp, "$PTS", 4) || !strncmp(tmp, "$NO", 3) || 
        !strncmp(tmp, "$PARA", 5) || !strncmp(tmp, "$ELM", 4) ||
        !strncmp(tmp, "$MeshFormat", 11)) {
-      if(!GMODEL) GMODEL = new gmshModel;
       status = GMODEL->readMSH(name);
     }
     else if(!strncmp(tmp, "$PostFormat", 11) || !strncmp(tmp, "$View", 5)) {
@@ -352,6 +347,10 @@ void OpenProblem(char *name)
   }
   CTX.threads_lock = 1;
 
+  // recreate a brand new gmsh model
+  if(GMODEL) delete GMODEL;
+  GMODEL = new gmshModel;
+
   Init_Mesh();
 
   // Initialize pseudo random mesh generator to the same seed