diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index c62826c28441d409aef064b60b96c0eacacbb29e..827332eaaaec01169c76fe7c352da1426f14b010 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -1,4 +1,4 @@
-// $Id: CommandLine.cpp,v 1.19 2003-06-13 16:53:07 geuzaine Exp $
+// $Id: CommandLine.cpp,v 1.20 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -75,7 +75,7 @@ void Print_Usage(char *name){
   Msg(DIRECT, "  -format msh|unv|gref  set output mesh format (default: msh)");
   Msg(DIRECT, "  -algo iso|tri|aniso   select 2D mesh algorithm (default: iso)");
   Msg(DIRECT, "  -smooth int           set mesh smoothing (default: 0)");
-  //  Msg(DIRECT, "  -degree int           set mesh degree (default: 1)");
+  Msg(DIRECT, "  -order int            set mesh order (default: 1)");
   Msg(DIRECT, "  -scale float          set global scaling factor (default: 1.0)");
   Msg(DIRECT, "  -meshscale float      set mesh scaling factor (default: 1.0)");
   Msg(DIRECT, "  -clscale float        set characteristic length scaling factor (default: 1.0)");
@@ -348,10 +348,10 @@ void Get_Options(int argc, char *argv[], int *nbfiles)
           exit(1);
         }
       }
-      else if(!strcmp(argv[i] + 1, "degree")) {
+      else if(!strcmp(argv[i] + 1, "order") || !strcmp(argv[i] + 1, "degree")) {
         i++;
         if(argv[i] != NULL)
-          opt_mesh_degree(0, GMSH_SET, atof(argv[i++]));
+          opt_mesh_order(0, GMSH_SET, atof(argv[i++]));
         else {
           fprintf(stderr, ERROR_STR "Missing number\n");
           exit(1);
diff --git a/Common/Context.h b/Common/Context.h
index 4fbcc3c473b0320841f3d93b3906e87e19bcd2a6..80072e2d251951aa6cf8fbfbc8d22b601f428282 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -158,7 +158,7 @@ public :
     double scaling_factor, lc_factor, rand_factor;
     int dual, interactive;
     int hidden, shade;
-    int format, nb_smoothing, algo, degree;
+    int format, nb_smoothing, algo, order;
     int point_insertion, speed_max, min_circ_points, constrained_bgmesh;
     int histogram, initial_only;
     double normals, tangents, explode;
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 1e3de084f524e7780caf34833b16913142efb93c..6a6b332b47a330b0bbab7549a7e3c9c6f637f342 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -690,13 +690,13 @@ StringXNumber MeshOptions_Number[] = {
   { F,   "CutPlaneD" , opt_mesh_cut_planed , 0. , 
     "Fourth cut plane equation coefficient (`D' in `AX+BY+CZ+D=0')" },
 
-  { F|O, "Degree" , opt_mesh_degree , 1. ,
-    "Element order" },
   { F|O, "DisplayLists" , opt_mesh_display_lists , 0. ,
     "Use OpenGL display lists for drawing meshes" },
   { F|O, "Dual" , opt_mesh_dual , 0. ,
     "Display the dual mesh obtained by barycentric subdivision" },
 
+  { F|O, "ElementOrder" , opt_mesh_order , 1. , // "Order" is already a lex token
+    "Element order (1=linear elements, 2=quadratic elements)" },
   { F|O, "Explode" , opt_mesh_explode , 1.0 ,
     "Display mesh with non adjacent elements (factor between 0 and 1)" },
 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 53d558b7c8736208cc71a6c21e7194ad797eebab..e088560188626a6dcd848fd2612bfa4741315af3 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.108 2003-06-13 21:14:20 geuzaine Exp $
+// $Id: Options.cpp,v 1.109 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -3264,15 +3264,15 @@ double opt_mesh_constrained_bgmesh(OPT_ARGS_NUM)
   return CTX.mesh.constrained_bgmesh;
 }
 
-double opt_mesh_degree(OPT_ARGS_NUM)
+double opt_mesh_order(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
-    CTX.mesh.degree = (int)val;
+    CTX.mesh.order = (int)val;
 #if defined(HAVE_FLTK)
   if(WID && (action & GMSH_GUI))
-    WID->mesh_butt[3]->value(CTX.mesh.degree == 2);
+    WID->mesh_butt[3]->value(CTX.mesh.order == 2);
 #endif
-  return CTX.mesh.degree;
+  return CTX.mesh.order;
 }
 
 double opt_mesh_dual(OPT_ARGS_NUM)
diff --git a/Common/Options.h b/Common/Options.h
index 087701ab17d62a7fb32d1322801790e1c257f5e5..882f51841d00b6834a74c6684b6a47865e529846 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -356,7 +356,7 @@ double opt_mesh_point_insertion(OPT_ARGS_NUM);
 double opt_mesh_speed_max(OPT_ARGS_NUM);
 double opt_mesh_min_circ_points(OPT_ARGS_NUM);
 double opt_mesh_constrained_bgmesh(OPT_ARGS_NUM);
-double opt_mesh_degree(OPT_ARGS_NUM);
+double opt_mesh_order(OPT_ARGS_NUM);
 double opt_mesh_dual(OPT_ARGS_NUM);
 double opt_mesh_interactive(OPT_ARGS_NUM);
 double opt_mesh_use_cut_plane(OPT_ARGS_NUM);
diff --git a/Common/Views.h b/Common/Views.h
index 604b8017a94acc51cab1b71f60b1d9e9acd6c646..9472557a5d612845ee5845b27ae8402da08fd02b 100644
--- a/Common/Views.h
+++ b/Common/Views.h
@@ -151,8 +151,6 @@ void CopyViewOptions(Post_View *src, Post_View *dest);
 void MergeViews(int all);
 
 int BGMWithView (Post_View *ErrView);
-int CreateBGM(Post_View *ErrView, int OptiMethod, double Degree,
-              double OptiValue, double *ObjFunct, char *OutFile);
 double ErrorInView(Post_View * ErrView, int *n);
 Post_View *Create2DGraph(char *xname, char *yname, int nbdata, double *x, double *y);
 
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index bb6f4a8589553a07e378fa330d4bbe1735d41ff7..1a73977e68d9ca09a28df33d284a7eb575dee33d 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.175 2003-04-14 22:37:07 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.176 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -959,7 +959,7 @@ void mesh_options_ok_cb(CALLBACK_ARGS)
                 WID->mesh_butt[0]->value()? DELAUNAY_ISO :
                 WID->mesh_butt[1]->value()? DELAUNAY_SHEWCHUK :
                 DELAUNAY_ANISO);
-  opt_mesh_degree(0, GMSH_SET, WID->mesh_butt[3]->value()? 2 : 1);
+  opt_mesh_order(0, GMSH_SET, WID->mesh_butt[3]->value()? 2 : 1);
   opt_mesh_interactive(0, GMSH_SET, WID->mesh_butt[4]->value());
   opt_mesh_constrained_bgmesh(0, GMSH_SET, WID->mesh_butt[5]->value());
   opt_mesh_points(0, GMSH_SET, WID->mesh_butt[6]->value());
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 5738937a7960a61b43295c4e795f5b00140c322b..85979c529376eb5af9c2876077d7f8d4eef33b73 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.237 2003-06-13 21:14:20 geuzaine Exp $
+// $Id: GUI.cpp,v 1.238 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -1638,6 +1638,7 @@ void GUI::create_option_window()
       mesh_butt[3]->type(FL_TOGGLE_BUTTON);
       mesh_butt[3]->down_box(TOGGLE_BOX);
       mesh_butt[3]->selection_color(TOGGLE_COLOR);
+      mesh_butt[3]->deactivate();
 
       mesh_butt[5] = new Fl_Check_Button(2 * WB, 2 * WB + 6 * BH, BW, BH, "Constrain background mesh");
       mesh_butt[5]->type(FL_TOGGLE_BUTTON);
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 46d1a8848fc60cb798e4733be3dbd45c525cc07f..45af263322cc2b9a2562f1b8508f8f66d82da983 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.60 2003-06-13 21:14:20 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.61 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -812,7 +812,7 @@ void Draw_Simplex_Curves(void *a, void *b)
     glDisable(GL_LIGHTING);
 
   if(CTX.mesh.lines) {
-    glBegin(GL_LINES);
+    glBegin(GL_LINE_STRIP);
     for(int i = 0; i < N; i++){
       glVertex3d(X[i], Y[i], Z[i]);
     }
diff --git a/Mesh/1D_Mesh.cpp b/Mesh/1D_Mesh.cpp
index f5e24bb5412880d9f740d42b50f9863e46ebe360..c9f4cb2ee0589a744b75f723a505dd6324a77931 100644
--- a/Mesh/1D_Mesh.cpp
+++ b/Mesh/1D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 1D_Mesh.cpp,v 1.32 2003-03-21 00:52:39 geuzaine Exp $
+// $Id: 1D_Mesh.cpp,v 1.33 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -251,7 +251,7 @@ void Maillage_Curve(void *data, void *dummy)
     List_Add(c->TrsfSimplexes, &s);
   }
 
-  if(CTX.mesh.degree == 2)
+  if(CTX.mesh.order == 2)
     Degre2(THEM->Vertices, THEM->VertexEdges, c->Simplexes, c, NULL);
 
   THEM->Statistics[4] += List_Nbr(c->Vertices);
diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp
index 5add806e5ac6c05d0c996a7559c311bc030edc99..585da02d329fa4215dda93f0d1cfdf22b8f60fce 100644
--- a/Mesh/2D_Mesh.cpp
+++ b/Mesh/2D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh.cpp,v 1.47 2003-03-21 00:52:40 geuzaine Exp $
+// $Id: 2D_Mesh.cpp,v 1.48 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -947,7 +947,7 @@ void Maillage_Surface(void *data, void *dum)
     Tree_Action(THEM->Points, PutVertex_OnSurf);
     Tree_Action(s->Vertices, PutVertex_OnSurf);
     Tree_Action(s->Vertices, Add_In_Mesh);
-    if(CTX.mesh.degree == 2)
+    if(CTX.mesh.order == 2)
       Degre2(THEM->Vertices, s->Vertices, s->Simplexes, NULL, s);
     THEM->Statistics[5] += Tree_Nbr(THESURFACE->Vertices);
     THEM->Statistics[7] += Tree_Nbr(THESURFACE->Simplexes);
@@ -1020,7 +1020,7 @@ void Maillage_Surface(void *data, void *dum)
   End_Surface(s->Support);
   End_Surface(s);
 
-  if(CTX.mesh.degree == 2)
+  if(CTX.mesh.order == 2)
     Degre2(THEM->Vertices, THEM->VertexEdges, s->Simplexes, NULL, THESUPPORT);
 
   THEM->Statistics[5] += Tree_Nbr(THESURFACE->Vertices);
diff --git a/Mesh/3D_Mesh.cpp b/Mesh/3D_Mesh.cpp
index b3658862173cc0dacc99c787f2df51cd9c6a4ecb..1e5ea01b9b578ca6322e26df1ea6795dd1d5131c 100644
--- a/Mesh/3D_Mesh.cpp
+++ b/Mesh/3D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 3D_Mesh.cpp,v 1.50 2003-03-21 00:52:41 geuzaine Exp $
+// $Id: 3D_Mesh.cpp,v 1.51 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -1047,7 +1047,7 @@ void Maillage_Volume(void *data, void *dum)
     }
 #endif
 
-    if(CTX.mesh.degree == 2)
+    if(CTX.mesh.order == 2)
       Degre2(THEM->Vertices, THEM->VertexEdges, v->Simplexes, NULL, NULL);
 
     List_Delete(Simplexes_New);
diff --git a/Mesh/3D_Mesh_Old.cpp b/Mesh/3D_Mesh_Old.cpp
index 743ace6c92ac25677756790c05055613794c651f..0f5a72050f1b2fbe400ac8e86943e8e33c4406cf 100644
--- a/Mesh/3D_Mesh_Old.cpp
+++ b/Mesh/3D_Mesh_Old.cpp
@@ -1,4 +1,4 @@
-// $Id: 3D_Mesh_Old.cpp,v 1.7 2003-03-21 00:52:41 geuzaine Exp $
+// $Id: 3D_Mesh_Old.cpp,v 1.8 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -906,7 +906,7 @@ void Maillage_Volume(void *data, void *dum)
        */
     }
 
-    if(CTX.mesh.degree == 2)
+    if(CTX.mesh.order == 2)
       Degre2(THEM->Vertices, THEM->VertexEdges, v->Simplexes, NULL, NULL);
 
     List_Delete(Simplexes_New);
diff --git a/Mesh/SecondOrder.cpp b/Mesh/SecondOrder.cpp
index 90ac61093a7ab3448cc0e7ed41b1846537f5d574..9dd177da5e39d653bf6ef32b55970dc1ebe730cf 100644
--- a/Mesh/SecondOrder.cpp
+++ b/Mesh/SecondOrder.cpp
@@ -1,4 +1,4 @@
-// $Id: SecondOrder.cpp,v 1.14 2003-06-13 21:14:20 geuzaine Exp $
+// $Id: SecondOrder.cpp,v 1.15 2003-06-13 22:41:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
 //
@@ -38,17 +38,46 @@ Vertex *middlecurve(Vertex * v1, Vertex * v2)
   if(!THEC)
     return NULL;
 
-  if((v1->ListCurves && List_Nbr(v1->ListCurves) != 1) ||
-     (v2->ListCurves && List_Nbr(v2->ListCurves) != 1)) {
+  int ok1 = 1, ok2 = 1;
+  double u1 = 0., u2 = 0.;
+
+  if(List_Nbr(v1->ListCurves) == 1){
+    u1 = v1->u;
+  }
+  else if(v1->Num == THEC->beg->Num){
+    u1 = THEC->ubeg;
+  }
+  else if(v1->Num == THEC->end->Num){
+    u1 = THEC->uend;
+  }
+  else{
+    ok1 = 0;
+  }
+
+  if(List_Nbr(v2->ListCurves) == 1){
+    u2 = v2->u;
+  }
+  else if(v2->Num == THEC->beg->Num){
+    u2 = THEC->ubeg;
+  }
+  else if(v2->Num == THEC->end->Num){
+    u2 = THEC->uend;
+  }
+  else{
+    ok2 = 0;
+  }
+
+  if(ok1 && ok2){
+    v = InterpolateCurve(THEC, 0.5 * (u1 + u2), 0);
+  }
+  else{
+    // too bad (should normally not happen)
     v.Pos.X = (v1->Pos.X + v2->Pos.X) * 0.5;
     v.Pos.Y = (v1->Pos.Y + v2->Pos.Y) * 0.5;
     v.Pos.Z = (v1->Pos.Z + v2->Pos.Z) * 0.5;
   }
-  else
-    v = InterpolateCurve(THEC, 0.5 * (v1->u + v2->u), 0);
 
-  pv =
-    Create_Vertex(++THEM->MaxPointNum, v.Pos.X, v.Pos.Y, v.Pos.Z, v.lc, v.u);
+  pv = Create_Vertex(++THEM->MaxPointNum, v.Pos.X, v.Pos.Y, v.Pos.Z, v.lc, v.u);
 
   if(!pv->ListCurves) {
     pv->ListCurves = List_Create(1, 1, sizeof(Curve *));
@@ -73,8 +102,7 @@ Vertex *middleface(Vertex * v1, Vertex * v2)
   U = 0.5 * (U1 + U2);
   V = 0.5 * (V1 + V2);
   v = InterpolateSurface(THES, U, V, 0, 0);
-  pv =
-    Create_Vertex(++THEM->MaxPointNum, v.Pos.X, v.Pos.Y, v.Pos.Z, v.lc, v.u);
+  pv = Create_Vertex(++THEM->MaxPointNum, v.Pos.X, v.Pos.Y, v.Pos.Z, v.lc, v.u);
   return pv;
 }
 
@@ -93,22 +121,30 @@ void PutMiddlePoint(void *a, void *b)
 
   ed = (Edge *) a;
 
-  if(ed->newv)
+  if(ed->newv){
     v = ed->newv;
-  else if((v = middlecurve(ed->V[0], ed->V[1])));
-  else if((v = middleface(ed->V[0], ed->V[1])));
-  else
+  }
+  else if((v = middlecurve(ed->V[0], ed->V[1]))){
+    ;
+  }
+  else if((v = middleface(ed->V[0], ed->V[1]))){
+    ;
+  }
+  else{
     v = Create_Vertex(++THEM->MaxPointNum,
                       0.5 * (ed->V[0]->Pos.X + ed->V[1]->Pos.X),
                       0.5 * (ed->V[0]->Pos.Y + ed->V[1]->Pos.Y),
                       0.5 * (ed->V[0]->Pos.Z + ed->V[1]->Pos.Z),
                       0.5 * (ed->V[0]->lc + ed->V[1]->lc),
                       0.5 * (ed->V[0]->u + ed->V[1]->u));
+  }
+
   ed->newv = v;
   Tree_Insert(THET, &v);
+
   for(i = 0; i < List_Nbr(ed->Simplexes); i++) {
     List_Read(ed->Simplexes, i, &s);
-    if(s->V[3] && EdgesInVolume) {
+    if(s->V[3] && EdgesInVolume) { // tetrahedron
       if(!s->VSUP)
         s->VSUP = (Vertex **) Malloc(6 * sizeof(Vertex *));
       N = 6;
@@ -116,7 +152,7 @@ void PutMiddlePoint(void *a, void *b)
         for(j = 0; j < 2; j++)
           edges[k][j] = edges_tetra[k][j];
     }
-    else if(s->V[3]) {
+    else if(s->V[3]) { // quadrangle
       if(!s->VSUP)
         s->VSUP = (Vertex **) Malloc(4 * sizeof(Vertex *));
       N = 4;
@@ -124,7 +160,7 @@ void PutMiddlePoint(void *a, void *b)
         for(j = 0; j < 2; j++)
           edges[k][j] = edges_quad[k][j];
     }
-    else if(s->V[2]) {
+    else if(s->V[2]) { // triangle
       if(!s->VSUP)
         s->VSUP = (Vertex **) Malloc(3 * sizeof(Vertex *));
       N = 3;
@@ -132,7 +168,7 @@ void PutMiddlePoint(void *a, void *b)
         for(j = 0; j < 2; j++)
           edges[k][j] = edges_tetra[k][j];
     }
-    else {
+    else { // line
       if(!s->VSUP)
         s->VSUP = (Vertex **) Malloc(sizeof(Vertex *));
       N = 1;