diff --git a/Common/Visibility.h b/Common/Visibility.h
index b6f5001244d93659ffe953305829838d3e2113f0..382a423094a34c1a4d91508de0bf506c6bee404d 100644
--- a/Common/Visibility.h
+++ b/Common/Visibility.h
@@ -122,6 +122,9 @@ class VisibilityManager {
   // get the number of entities in the manager
   int getNumEntities() { return _entities.size(); }
 
+  // get the number of entities in the manager
+  Vis *getEntity(int i) { return _entities[i]; }
+
   // get the visibility information for the nth entity in the manager
   char getVisibility(int n){ return _entities[n]->getVisibility(); }
 
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 872bdf898edb56b261906ed207096b3d07ad5c8d..2b2d2592a0d817833204f08dc9773e780d1b4fb6 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.507 2007-01-24 10:53:04 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.508 2007-01-25 08:56:13 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -1915,8 +1915,8 @@ void visibility_cb(CALLBACK_ARGS)
     if(VisibilityManager::instance()->getVisibility(i))
       WID->vis_browser->select(i + 1);
   }
-  // active the delete button for physicals and partitions only!
-  if(type == 1 || type == 2)
+  // active the delete button for physicals only!
+  if(type == 1)
     WID->vis_push_butt[0]->activate();
   else
     WID->vis_push_butt[0]->deactivate();
@@ -1954,7 +1954,6 @@ void visibility_ok_cb(CALLBACK_ARGS)
 
 void visibility_save_cb(CALLBACK_ARGS)
 {
-  visibility_ok_cb(NULL, NULL);
   std::string str = VisibilityManager::instance()->getStringForGEO();
   add_infile((char*)str.c_str(), CTX.filename);
 }
@@ -1962,10 +1961,27 @@ void visibility_save_cb(CALLBACK_ARGS)
 void visibility_delete_cb(CALLBACK_ARGS)
 {
   int type = WID->vis_type->value();
-  if(type == 1)
+  if(type != 1) return; // delete only available for physicals
+
+  bool all = true;
+  for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++){
+    if(!WID->vis_browser->selected(i + 1)){
+      all = false;
+      break;
+    }
+  }
+  if(all){
     GMODEL->deletePhysicalGroups();
-  else if(type == 2)
-    GMODEL->deleteMeshPartitions();
+  }
+  else{
+    for(int i = 0; i < VisibilityManager::instance()->getNumEntities(); i++){
+      if(WID->vis_browser->selected(i + 1)){
+	Vis *v = VisibilityManager::instance()->getEntity(i);
+	GMODEL->deletePhysicalGroup(v->getDim(), v->getTag());
+      }
+    }
+  }
+
   visibility_cb(NULL, (void*)"redraw_only");
 }
 
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 6ed6dc40fa574832319c94b55e1e56c995c20139..3b557d504049f4829cf3fe257e45c18ff9e96966 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.594 2007-01-24 10:53:04 geuzaine Exp $
+// $Id: GUI.cpp,v 1.595 2007-01-25 08:56:13 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -3923,7 +3923,7 @@ void GUI::create_visibility_window(bool redraw_only)
     Fl_Button *o5 = new Fl_Button(width - 4 * WB, 3 * WB + 2 * BH, 2 * WB, BH, "+");
     o5->tooltip("Add parameter name for first selected item");
     o5->callback(visibility_sort_cb, (void *)"+");
-    
+
     {
       Fl_Group *o = new Fl_Group(2 * WB, 3 * WB + 3 * BH, brw, height - 7 * WB - 5 * BH);
       
@@ -3935,15 +3935,12 @@ void GUI::create_visibility_window(bool redraw_only)
       Fl_Group::current()->resizable(o);
     }
 
-    vis_push_butt[0] = new Fl_Button(width - 3 * BB - 4 * WB, height - 2 * BH - 3 * WB, BB, BH, "Delete");
+    vis_push_butt[0] = new Fl_Button(width - 2 * BB - 3 * WB, height - 2 * BH - 3 * WB, BB, BH, "Delete");
     vis_push_butt[0]->callback(visibility_delete_cb);
 
-    Fl_Return_Button *b1 = new Fl_Return_Button(width - 2 * BB - 3 * WB, height - 2 * BH - 3 * WB, BB, BH, "Apply");
+    Fl_Return_Button *b1 = new Fl_Return_Button(width - 1 * BB - 2 * WB, height - 2 * BH - 3 * WB, BB, BH, "Apply");
     b1->callback(visibility_ok_cb);
 
-    Fl_Button *b2 = new Fl_Button(width - BB - 2 * WB, height - 2 * BH - 3 * WB, BB, BH, "Save");
-    b2->callback(visibility_save_cb);
-
     vis_group[0]->end();
     Fl_Group::current()->resizable(vis_group[0]);
   }
@@ -4032,8 +4029,11 @@ void GUI::create_visibility_window(bool redraw_only)
   vis_window->size_range(width, 9 * BH + 6 * WB, width);
 
   {
-    Fl_Button *o = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
-    o->callback(cancel_cb, (void *)vis_window);
+    Fl_Button *o1 = new Fl_Button(width - 2 * BB - 2 * WB, height - BH - WB, BB, BH, "Save");
+    o1->callback(visibility_save_cb);
+
+    Fl_Button *o2 = new Fl_Button(width - BB - WB, height - BH - WB, BB, BH, "Cancel");
+    o2->callback(cancel_cb, (void *)vis_window);
   }
 
   vis_window->position(CTX.vis_position[0], CTX.vis_position[1]);
diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index e3f31b1f4ce0b35b6a3d823fdef46b83bfd48a48..cbffedb8a16ab5155f492e58ecda16885eb35d9e 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -1,4 +1,4 @@
-// $Id: GModel.cpp,v 1.29 2007-01-22 16:31:43 geuzaine Exp $
+// $Id: GModel.cpp,v 1.30 2007-01-25 08:56:14 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -185,6 +185,44 @@ void GModel::deletePhysicalGroups()
     (*it)->physicals.clear();
 }
 
+void GModel::deletePhysicalGroup(int dim, int num)
+{
+  switch(dim){
+  case 0:
+    for(viter it = firstVertex(); it != lastVertex(); ++it){
+      std::vector<int> p;
+      for(unsigned int i = 0; i < (*it)->physicals.size(); i++)
+	if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]);
+      (*it)->physicals = p;
+    }
+    break;
+  case 1:
+    for(eiter it = firstEdge(); it != lastEdge(); ++it){
+      std::vector<int> p;
+      for(unsigned int i = 0; i < (*it)->physicals.size(); i++)
+	if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]);
+      (*it)->physicals = p;
+    }
+    break;
+  case 2:
+    for(fiter it = firstFace(); it != lastFace(); ++it){
+      std::vector<int> p;
+      for(unsigned int i = 0; i < (*it)->physicals.size(); i++)
+	if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]);
+      (*it)->physicals = p;
+    }
+    break;
+  case 3:
+    for(riter it = firstRegion(); it != lastRegion(); ++it){
+      std::vector<int> p;
+      for(unsigned int i = 0; i < (*it)->physicals.size(); i++)
+	if((*it)->physicals[i] != num) p.push_back((*it)->physicals[i]);
+      (*it)->physicals = p;
+    }
+    break;
+  }
+}
+
 int GModel::maxPhysicalNumber()
 {
   int num = 0;
diff --git a/Geo/GModel.h b/Geo/GModel.h
index 99d25366e206fc0fc69dbdca40c96a5b8813d6bb..091fe5c25e6e1c1e741bc9a319c53022bf29259d 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -110,8 +110,9 @@ class GModel
   // Returns all physical groups (one map per dimension: 0-D to 3-D)
   void getPhysicalGroups(std::map<int, std::vector<GEntity*> > groups[4]);
 
-  // Deletes all physical groups in the model
+  // Deletes physical groups in the model
   void deletePhysicalGroups();
+  void deletePhysicalGroup(int dim, int num);
 
   // Returns the highest number associated with a physical entity
   int maxPhysicalNumber();
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 4d2596beb4dfb1373a5b16a209f922ececf770e9..1947d0b8ec32d377fca5875c416c7c8fda520484 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.193 2007-01-23 08:01:08 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.194 2007-01-25 08:56:14 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -562,15 +562,15 @@ class drawMeshGEdge {
   {  
     if(!e->getVisibility()) return;
     
+    MRep *m = e->meshRep;
+
+    if(!m) return;
+
     if(CTX.render_mode == GMSH_SELECT) {
       glPushName(1);
       glPushName(e->tag());
     }
 
-    MRep *m = e->meshRep;
-
-    if(!m) return;
-
     if(CTX.mesh.lines)
       drawArrays(e, m->va_lines, GL_LINES, false);
 
@@ -785,15 +785,15 @@ class drawMeshGRegion {
   {  
     if(!r->getVisibility()) return;
 
+    MRep *m = r->meshRep;
+
+    if(!m) return;
+
     if(CTX.render_mode == GMSH_SELECT) {
       glPushName(3);
       glPushName(r->tag());
     }
 
-    MRep *m = r->meshRep;
-
-    if(!m) return;
-
     if(CTX.mesh.volumes_edges){
       if(m->va_lines && m->va_lines->getNumVertices()){
 	drawArrays(r, m->va_lines, GL_LINES, CTX.mesh.light && CTX.mesh.light_lines, 
@@ -880,7 +880,7 @@ void Draw_Mesh()
     CTX.threads_lock = 1; 
     int status = GMODEL->getMeshStatus();
     if(CTX.mesh.changed) {
-      Msg(DEBUG, "Mesh has changed: reinitializing drawing data");
+      Msg(DEBUG, "Mesh has changed: reinitializing drawing data", CTX.mesh.changed);
       if(status >= 1 && CTX.mesh.changed & ENT_LINE)
 	std::for_each(GMODEL->firstEdge(), GMODEL->lastEdge(), initMeshGEdge());
       if(status >= 2 && CTX.mesh.changed & ENT_SURFACE){