diff --git a/Common/Options.cpp b/Common/Options.cpp
index e23d4f30a0bf86f8f3efa0c9996f4ff917bf6a5a..5b3e749d16e5f6a6a412c20019a3aeba3dd19c9f 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.313 2006-11-01 22:19:26 geuzaine Exp $
+// $Id: Options.cpp,v 1.314 2006-11-02 17:24:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -4992,7 +4992,8 @@ double opt_mesh_color_carousel(OPT_ARGS_NUM)
   if(action & GMSH_SET) {
     // vertex arrays need to be regenerated only when we color by
     // element type or by partition
-    if(CTX.mesh.color_carousel != (int)val && (val == 0. || val == 3.))
+    if(CTX.mesh.color_carousel != (int)val && 
+       ((val == 0. || val == 3.) || CTX.pick_elements))
       CTX.mesh.changed = ENT_LINE | ENT_SURFACE | ENT_VOLUME;
     CTX.mesh.color_carousel = (int)val;
     if(CTX.mesh.color_carousel < 0 || CTX.mesh.color_carousel > 3)
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index af36f2fd17d6ba095eff1622465d2dd9e67a2b57..42215a98325df6fa9fcb49a0c610ae186ce3f307 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.466 2006-11-02 00:56:31 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.467 2006-11-02 17:24:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -3540,7 +3540,8 @@ void mesh_delete_parts_cb(CALLBACK_ARGS)
       Msg(ONSCREEN, "Select %s\n"
 	  "[Press 'e' to end selection or 'q' to abort]", str);
 
-    char ib = SelectEntity(ENT_ALL, vertices, edges, faces, regions, elements);
+    char ib = SelectEntity(CTX.pick_elements ? ENT_ALL : ENT_SURFACE, 
+			   vertices, edges, faces, regions, elements);
     if(ib == 'l') {
       if(CTX.pick_elements){
 	for(unsigned int i = 0; i < elements.size(); i++){
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 654bb21cfaad2855423dc15e6fcc5552cedca71c..aac7daebdd9db4f7af20322f8bc517cebc8f0043 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.186 2006-11-01 22:19:26 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.187 2006-11-02 17:24:54 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -70,10 +70,7 @@ static unsigned int getColorByElement(MElement *ele)
     default: return CTX.color.geom.volume_sel;
     }
   }
-  else if(CTX.mesh.color_carousel == 3){ // by partition
-    return CTX.color.mesh.carousel[abs(ele->getPartition() % 20)];
-  }
-  else{ // by element type
+  else if(CTX.mesh.color_carousel == 0){ // by element type
     switch(ele->getNumEdges()){
     case 1: return CTX.color.mesh.line;
     case 3: return CTX.color.mesh.triangle;
@@ -85,6 +82,17 @@ static unsigned int getColorByElement(MElement *ele)
     default: return CTX.color.mesh.vertex;
     }
   }
+  else if(CTX.mesh.color_carousel == 3){ // by partition
+    return CTX.color.mesh.carousel[abs(ele->getPartition() % 20)];
+  }
+  else{ // by entity
+    for(int i = 0; i < ele->getNumVertices(); i++){
+      GEntity *e = ele->getVertex(i)->onWhat();
+      if(e->dim() == ele->getDim()) 
+	return getColorByEntity(e);
+    }
+  }
+  return CTX.color.fg;
 }
 
 static double intersectCutPlane(MElement *ele)
diff --git a/Graphics/SelectBuffer.cpp b/Graphics/SelectBuffer.cpp
index 85b793e3fa2300843cc6923f548e9d0db02cfe2b..c39f74c267fda45d68b016cb564942e77985eb76 100644
--- a/Graphics/SelectBuffer.cpp
+++ b/Graphics/SelectBuffer.cpp
@@ -1,4 +1,4 @@
-// $Id: SelectBuffer.cpp,v 1.6 2006-11-01 22:19:27 geuzaine Exp $
+// $Id: SelectBuffer.cpp,v 1.7 2006-11-02 17:24:54 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -63,9 +63,9 @@ bool ProcessSelectionBuffer(int entityType,
 
   // In our case the selection buffer size is equal to between 5 and 7
   // times the maximum number of possible hits
-  int eles = (meshSelection && CTX.pick_elements) ? 3 * GMODEL->numElement() : 0;
+  int eles = (meshSelection && CTX.pick_elements) ? 4 * GMODEL->numElement() : 0;
   int size = 7 * (GMODEL->numVertex() + GMODEL->numEdge() + GMODEL->numFace() + 
-		  GMODEL->numRegion() + eles) ;
+		  GMODEL->numRegion() + eles) + 1000 ;
 
   GLuint *selectionBuffer = new GLuint[size];
   glSelectBuffer(size, selectionBuffer);
@@ -90,7 +90,7 @@ bool ProcessSelectionBuffer(int entityType,
   }
   else if(numhits < 0){ // overflow
     delete [] selectionBuffer;
-    Msg(WARNING, "Selection buffer size exceeded");
+    Msg(WARNING, "Too many entities selected");
     return false;
   }