diff --git a/Common/Context.h b/Common/Context.h
index f02a6e4e1f3e60a420e69727a237724ead490b66..97b1cc26b6c230895b0ae9b09045e8bd50d40eaa 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -1,4 +1,4 @@
-/* $Id: Context.h,v 1.23 2000-12-21 12:30:36 geuzaine Exp $ */
+/* $Id: Context.h,v 1.24 2000-12-27 17:25:52 geuzaine Exp $ */
 #ifndef _CONTEXT_H_
 #define _CONTEXT_H_
 
@@ -123,6 +123,7 @@ class Context_T {
     int draw;
     int points, lines, surfaces, volumes;
     int points_num, lines_num, surfaces_num, volumes_num;
+    double quality;
     double limit_gamma, limit_eta, limit_rho;
     double scaling_factor, lc_factor, rand_factor;
     int dual, interactive;
diff --git a/Common/Options.h b/Common/Options.h
index 8217925f05b75d61b1d7b2d7c337eae8918cb8cf..d60e256018bc168adfeeaa2aa179f6027761ea8e 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -1,4 +1,4 @@
-/* $Id: Options.h,v 1.12 2000-12-21 12:30:36 geuzaine Exp $ */
+/* $Id: Options.h,v 1.13 2000-12-27 17:25:52 geuzaine Exp $ */
 #ifndef _OPTIONS_H_
 #define _OPTIONS_H_
 
@@ -151,6 +151,7 @@ StringXNumber GeometryOptions_Number[] = {
 } ;
 
 StringXNumber MeshOptions_Number[] = {
+  { "Quality"         , GMSH_DOUBLE, (void*)&CTX.mesh.quality        , 0.0 }, 
   { "Normals"         , GMSH_DOUBLE, (void*)&CTX.mesh.normals        , 0.0 }, 
   { "Tangents"        , GMSH_DOUBLE, (void*)&CTX.mesh.tangents       , 0.0 }, 
   { "Explode"         , GMSH_DOUBLE, (void*)&CTX.mesh.explode        , 1.0 }, 
diff --git a/Mesh/3D_Mesh.cpp b/Mesh/3D_Mesh.cpp
index 8db7ae71a0f947ee6b8400276ecae4cf7efb13f8..051afd80e7e67b7ad020ec625ff10b2b0dd76e73 100644
--- a/Mesh/3D_Mesh.cpp
+++ b/Mesh/3D_Mesh.cpp
@@ -1,4 +1,4 @@
-/* $Id: 3D_Mesh.cpp,v 1.11 2000-11-28 19:36:41 geuzaine Exp $ */
+/* $Id: 3D_Mesh.cpp,v 1.12 2000-12-27 17:25:52 geuzaine Exp $ */
 /*
  
   J-F Remacle 1995
@@ -839,12 +839,18 @@ void Maillage_Volume (void *data, void *dum){
     
     Progress(-1);
 
-    if (CTX.mesh.nb_smoothing){
-      /*
+    if (CTX.mesh.quality){
+      extern void SwapEdges3D (Mesh * M, Volume * v, double GammaPrescribed, bool order);
       Msg(STATUS, "Swapping Edges (1st pass)");
-      SwapEdges3D (THEM, v, 0.5, true);
+      SwapEdges3D (THEM, v, CTX.mesh.quality, true);
       Msg(STATUS, "Swapping Edges (2nd pass)");
-      SwapEdges3D (THEM, v, 0.5, false);
+      SwapEdges3D (THEM, v, CTX.mesh.quality, false);
+      Msg(STATUS, "Swapping Edges (last pass)");
+      SwapEdges3D (THEM, v, CTX.mesh.quality, true);
+    }
+
+    if (CTX.mesh.nb_smoothing){
+      /*
       Msg(STATUS, "Laplacian Smoothing");
       tnxe = Tree_Create (sizeof (NXE), compareNXE);
       create_NXE (v->Vertices, v->Simplexes, tnxe);
diff --git a/Unix/Main.cpp b/Unix/Main.cpp
index 4430a8f052698b657e924c224a6bf027b9bb7f0b..9c4b7bdefeb47f42c867c1a7ec49ce081b3d2b5c 100644
--- a/Unix/Main.cpp
+++ b/Unix/Main.cpp
@@ -1,4 +1,4 @@
-/* $Id: Main.cpp,v 1.33 2000-12-21 12:30:39 geuzaine Exp $ */
+/* $Id: Main.cpp,v 1.34 2000-12-27 17:25:52 geuzaine Exp $ */
 
 #include <signal.h>
 
@@ -248,6 +248,14 @@ void Get_Options (int argc, char *argv[], int *nbfiles) {
       else if(!strcmp(argv[i]+1, "interactive")){ 
         CTX.mesh.interactive = 1; i++;
       }
+      else if(!strcmp(argv[i]+1, "quality")){
+        i++;
+        if(argv[i]!=NULL) CTX.mesh.quality = atof(argv[i++]);
+        else {    
+          fprintf(stderr, ERROR_STR "Missing Number\n");
+          exit(1);
+        }
+      }
       else if(!strcmp(argv[i]+1, "scale")){
         i++;
         if(argv[i]!=NULL) CTX.geom.scaling_factor = atof(argv[i++]);
diff --git a/doc/FORMATS b/doc/FORMATS
index b97f58a373f5009b5bc999bb72b20f9bbb7a8c5d..369094f8fe5825223b828100e77f796d636c2b34 100644
--- a/doc/FORMATS
+++ b/doc/FORMATS
@@ -1,4 +1,4 @@
-$Id: FORMATS,v 1.6 2000-12-26 20:45:42 geuzaine Exp $
+$Id: FORMATS,v 1.7 2000-12-27 17:25:52 geuzaine Exp $
 
 This document describes the mesh and post-processing file formats for
 Gmsh, version >= 1.0. 
@@ -123,7 +123,7 @@ except that:
 
 1) file-type equals 1.
 
-2) all lists of double precision numbers are written in binary format
+2) all lists of floating point numbers are written in binary format
 
 3) there is an additional integer, of value 1, written before
    time-step-values. This integer serves to detect if the computer on