diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 1528539b57d087366e772e75de908d223cd5d442..0f587700f085795b16b3c4e8f3f872c6f759f922 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.304 2004-05-22 01:24:17 geuzaine Exp $
+// $Id: GUI.cpp,v 1.305 2004-05-22 01:29:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -874,7 +874,11 @@ void GUI::create_menu_window(int argc, char **argv)
   m_module_butt = new Fl_Choice(19, y, width - 24, BH);
   m_module_butt->menu(m_module_table);
   m_module_butt->box(FL_THIN_DOWN_BOX);
-
+  // force the executation of the callback even if we didn't change
+  // the selection (we want to go back to the top-level menu every
+  // time we select one of the categories, even if the category is not
+  // changed):
+  m_module_butt->when(FL_WHEN_RELEASE_ALWAYS);
   y = MH;
 
   for(i = 0; i < NB_BUTT_MAX; i++) {
@@ -1265,7 +1269,9 @@ void GUI::make_opengl_current()
 
 void GUI::redraw_opengl()
 {
+  g_opengl_window->make_current();
   g_opengl_window->redraw();
+  check();
 }
 
 // Create the option window
diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp
index d9c8ab7bc30b00b1136b2264df98945fed4eadc9..20bda3753e064839ee09d9481b66dba65b8ab1d6 100644
--- a/Fltk/Opengl.cpp
+++ b/Fltk/Opengl.cpp
@@ -1,4 +1,4 @@
-// $Id: Opengl.cpp,v 1.41 2004-05-19 07:44:51 geuzaine Exp $
+// $Id: Opengl.cpp,v 1.42 2004-05-22 01:29:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -66,14 +66,8 @@ void Draw(void)
   WID->redraw_opengl();
 }
 
-void DrawUI(void)
-{
-  WID->check();
-}
-
 void Draw_String(char *s)
 {
-
   if(CTX.print.gl_fonts) {
     gl_font(CTX.gl_font_enum, CTX.gl_fontsize);
     gl_draw(s);
diff --git a/Graphics/Draw.h b/Graphics/Draw.h
index 1bbb2b957b3a8f391a969910b4087fcae28f133b..80aac8ae6b3e96a6aa2fd03a8f38f65bd064b52b 100644
--- a/Graphics/Draw.h
+++ b/Graphics/Draw.h
@@ -55,7 +55,6 @@ void ZeroHighlightEntityNum(int v, int c, int s);
 
 void Draw3d(void);
 void Draw2d(void);
-void DrawUI(void);
 void Draw(void);
 
 void Draw_String(char *s);
diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp
index 844b9918396ac523d14806eee539b7f4dcf7b896..7f0cda03e9fd414a4b63ca306bc6d6804760436b 100644
--- a/Graphics/Geom.cpp
+++ b/Graphics/Geom.cpp
@@ -1,4 +1,4 @@
-// $Id: Geom.cpp,v 1.61 2004-05-19 18:43:15 geuzaine Exp $
+// $Id: Geom.cpp,v 1.62 2004-05-22 01:29:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -256,9 +256,9 @@ int isPointOnPlanarSurface(Surface * S, double X, double Y, double Z,
 
   }
 
-  //printf(" %d -> angle %g\n", S->Num, fabs(Angle));
+  // if Angle == 2*pi, we're inside
 
-  if(fabs(Angle) > 6.0 && fabs(Angle) < 7.0)    // Should be 2 * Pi or 0
+  if(fabs(Angle) > 2*M_PI-0.5 && fabs(Angle) < 2*M_PI+0.5) 
     return 1;
   return 0;
 }
@@ -300,13 +300,15 @@ void Draw_Plane_Surface(Surface * s)
   double minx = 0., miny = 0., maxx = 0., maxy = 0., t, n[3];
   Vertex P1, P2, P3, V[4], vv, vv1, vv2;
   char Num[100];
+  const int numPoints = 100;
 
   if (s->thePolyRep) {
     Draw_Triangulated_Surface(s);
     return;
   }
 
-  if(List_Nbr(s->Orientations) < 1) {
+  if(!CTX.threads_lock && List_Nbr(s->Orientations) < 1) {
+    CTX.threads_lock = 1;
 
     List_T *points = List_Create(10, 10, sizeof(Vertex *));
     for(i = 0; i < List_Nbr(s->Generatrices); i++) {
@@ -359,8 +361,8 @@ void Draw_Plane_Surface(Surface * s)
     norme(n);
 
     k = 0;
-    for(i = 0; i < 100; i++) {
-      t = (double)i / (double)(100);
+    for(i = 0; i < numPoints; i++) {
+      t = (double)i / (double)(numPoints-1);
       vv.Pos.X = t * 0.5 * (V[0].Pos.X + V[1].Pos.X) + (1. - t) *
         0.5 * (V[2].Pos.X + V[3].Pos.X);
       vv.Pos.Y = t * 0.5 * (V[0].Pos.Y + V[1].Pos.Y) + (1. - t) *
@@ -385,8 +387,8 @@ void Draw_Plane_Surface(Surface * s)
       List_Add(s->Orientations, &vv);
 
     k = 0;
-    for(i = 0; i < 100; i++) {
-      t = (double)i / (double)(100);
+    for(i = 0; i < numPoints; i++) {
+      t = (double)i / (double)(numPoints-1);
       vv.Pos.X = t * .5 * (V[0].Pos.X + V[3].Pos.X) + 
 	(1. - t) * .5 * (V[2].Pos.X + V[1].Pos.X);
       vv.Pos.Y = t * .5 * (V[0].Pos.Y + V[3].Pos.Y) + 
@@ -413,6 +415,8 @@ void Draw_Plane_Surface(Surface * s)
 
     if(!List_Nbr(s->Orientations)) // add dummy
       List_Add(s->Orientations, &vv);
+
+    CTX.threads_lock = 0;
   }
 
   if(List_Nbr(s->Orientations) > 1) {
diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp
index 3d67ffbbd14ab63c1a268b10dce49c8a1b8030f1..180ccc867fbe0e82a1b08b2f4296825e073e9c33 100644
--- a/Mesh/2D_Mesh.cpp
+++ b/Mesh/2D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh.cpp,v 1.55 2004-05-07 18:42:48 geuzaine Exp $
+// $Id: 2D_Mesh.cpp,v 1.56 2004-05-22 01:29:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -833,7 +833,7 @@ void Maillage_Surface(void *data, void *dum)
   Tree_Action(s->Vertices, Projette_Plan_Moyen);
   Tree_Action(THEM->Curves, ActionEndTheCurve);
   s->Typ = MSH_SURF_PLAN;
-  End_Surface(s);
+  End_Surface(s, 0);
 
   ori = Calcule_Contours(s);
 
@@ -880,8 +880,8 @@ void Maillage_Surface(void *data, void *dum)
   Tree_Action(s->Vertices, Add_In_Mesh);
 
   Tree_Action(THEM->Curves, ActionEndTheCurve);
-  End_Surface(s->Support);
-  End_Surface(s);
+  End_Surface(s->Support, 0);
+  End_Surface(s, 0);
 
   THEM->Statistics[5] += Tree_Nbr(THESURFACE->Vertices);
   THEM->Statistics[7] += Tree_Nbr(THESURFACE->Simplexes);       // tri+qua
diff --git a/Mesh/2D_Mesh_Triangle.cpp b/Mesh/2D_Mesh_Triangle.cpp
index bc549357169c8b45996daebe584cfd5702c8c7e0..76616dd70a3b1bdae16fb8447b40d4ae7beac468 100644
--- a/Mesh/2D_Mesh_Triangle.cpp
+++ b/Mesh/2D_Mesh_Triangle.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh_Triangle.cpp,v 1.8 2004-05-22 01:24:17 geuzaine Exp $
+// $Id: 2D_Mesh_Triangle.cpp,v 1.9 2004-05-22 01:29:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -200,17 +200,33 @@ int Mesh_Shewchuk(Surface * s)
     return 0;
   }
 
-  // generalize this if we have a bgmesh!
   mid.trianglearealist =
     (REAL *) Malloc(mid.numberoftriangles * sizeof(REAL));
   for(i = 0; i < mid.numberoftriangles; i++) {
-    val = 0;
-    for(j = 0; j < mid.numberofcorners; j++) {
-      k = mid.trianglelist[i * mid.numberofcorners + j];
-      val += mid.pointattributelist[k];
+    //if(THEM->BGM.Typ == ONFILE) {
+    if(0) { 
+      double xx = 0.0, yy = 0.0;
+      for(j = 0; j < mid.numberofcorners; j++) {
+	k = mid.trianglelist[i * mid.numberofcorners + j];
+	xx += mid.pointlist[2 * k];
+	yy += mid.pointlist[2 * k + 1];
+      }
+      xx /= mid.numberofcorners;
+      yy /= mid.numberofcorners;
+      // project the point in real space; this is a mess, since we
+      // actually change the parameters of the surface in 2d_Mesh.cpp
+      // x =, y = , z = ; 
+      //val = Lc_XYZ(x, y, z, THEM);
+    }
+    else {
+      val = 0;
+      for(j = 0; j < mid.numberofcorners; j++) {
+	k = mid.trianglelist[i * mid.numberofcorners + j];
+	val += mid.pointattributelist[k];
+      }
+      val /= mid.numberofcorners;
+      val = val * val / 1.5; // approx (we want isotropic meshes)
     }
-    val /= mid.numberofcorners;
-    val = val * val / 1.5; // approx (we want isotropic meshes)
     mid.trianglearealist[i] = val;
   }
 
diff --git a/Mesh/Create.cpp b/Mesh/Create.cpp
index db6316f08a21d2f365f0ec3f296cac675efb6158..f5504391f2ab64ee5b1225e6c5410b736532af36 100644
--- a/Mesh/Create.cpp
+++ b/Mesh/Create.cpp
@@ -1,4 +1,4 @@
-// $Id: Create.cpp,v 1.53 2004-05-22 01:24:18 geuzaine Exp $
+// $Id: Create.cpp,v 1.54 2004-05-22 01:29:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -507,12 +507,12 @@ void End_Curve(Curve * c)
 
 }
 
-void End_Surface(Surface * s)
+void End_Surface(Surface * s, int reset_orientations)
 {
   int i;
   Vertex *v;
   
-  if(s->Orientations) 
+  if(reset_orientations) 
     List_Reset(s->Orientations);
 
   if(!s->Control_Points || !List_Nbr(s->Control_Points))
diff --git a/Mesh/Create.h b/Mesh/Create.h
index 885f900afc2a308db0a825a9bb15e3c91f346105..f0f95c7167e5d7a7051eea78753b14ec186ffd2b 100644
--- a/Mesh/Create.h
+++ b/Mesh/Create.h
@@ -69,7 +69,7 @@ void Free_EdgeLoop(void *a, void *b);
 void Free_SurfaceLoop(void *a, void *b);
 
 void End_Curve(Curve * c);
-void End_Surface(Surface * s);
+void End_Surface(Surface * s, int reset_orientations=1);
 
 int  Add_MeshPartition(int Num, Mesh * M);
 
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index f4d5996adf27b6a4094c955d3f48f391f9f833bd..c4a80d76dc49984d1966cc37844ef125646a1776 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,5 +1,5 @@
 %{
-// $Id: Gmsh.y,v 1.165 2004-05-14 18:23:58 geuzaine Exp $
+// $Id: Gmsh.y,v 1.166 2004-05-22 01:29:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -2415,10 +2415,8 @@ Command :
    | tDraw tEND
     {
 #if defined(HAVE_FLTK)
-      if(!CTX.batch){ // we're in interactive mode
+      if(!CTX.batch) // we're in interactive mode
 	Draw();
-	DrawUI();
-      }
 #endif
     }
 ;