diff --git a/hist/histpainter/src/TPainter3dAlgorithms.cxx b/hist/histpainter/src/TPainter3dAlgorithms.cxx
index 2ce206a..288e8f2 100644
--- a/hist/histpainter/src/TPainter3dAlgorithms.cxx
+++ b/hist/histpainter/src/TPainter3dAlgorithms.cxx
@@ -110,7 +110,7 @@ TPainter3dAlgorithms::TPainter3dAlgorithms(): TObject(), TAttLine(1,1,1), TAttFi
       fEdgeWidth = &gEdgeWidth[0];
    }
 
-   for (i=0;i<fNStack;i++) { fColorMain[i] = 1; fColorDark[i] = 1; fEdgeColor[i] = 1; fEdgeStyle[i] = 1; fEdgeWidth[i] = 1; }
+   for (i=0;i<fNStack;i++) { fColorMain[i] = 1; fColorDark[i] = 1; fEdgeColor[i] = kMagenta; fEdgeStyle[i] = 10; fEdgeWidth[i] = 10; }  /// default foolish values for errors to be spotted easily
    for (i=0;i<3;i++)       { fRmin[i] = 0, fRmax[i] = 1; }
    for (i=0;i<4;i++)       { fYls[i] = 0; }
 
@@ -194,7 +194,7 @@ TPainter3dAlgorithms::TPainter3dAlgorithms(Double_t *rmin, Double_t *rmax, Int_t
       fEdgeWidth = &gEdgeWidth[0];
    }
 
-   for (i=0;i<fNStack;i++) { fColorMain[i] = 1; fColorDark[i] = 1; fEdgeColor[i] = 1; fEdgeStyle[i] = 1; fEdgeWidth[i] = 1; }
+   for (i=0;i<fNStack;i++) { fColorMain[i] = 1; fColorDark[i] = 1; fEdgeColor[i] = kMagenta; fEdgeStyle[i] = 10; fEdgeWidth[i] = 10; }  /// default foolish values for errors to be spotted easily
    for (i=0;i<3;i++)       { fRmin[i] = rmin[i], fRmax[i] = rmax[i]; }
    for (i=0;i<4;i++)       { fYls[i] = 0; }
 
@@ -540,6 +540,12 @@ void TPainter3dAlgorithms::DrawFaceMode2(Int_t *icodes, Double_t *xyz, Int_t np,
    //          D R A W   F A C E   &   B O R D E R
    FillPolygon(np, p3, &t[1]);
    if (fMesh == 1) {
+      if (Hoption.Lego!=0 && Hoption.Surf==0) {  /// i.e. PaintFillArea for lego, not for surf
+         SetFillColor(fEdgeColor[fEdgeIdx]);
+         SetFillStyle(0);
+         TAttFill::Modify();
+         gPad->PaintFillArea(np, x, y);
+      }
       SetLineColor(fEdgeColor[fEdgeIdx]);
       SetLineStyle(fEdgeStyle[fEdgeIdx]);
       SetLineWidth(fEdgeWidth[fEdgeIdx]);
@@ -603,6 +609,10 @@ void TPainter3dAlgorithms::DrawFaceMode3(Int_t *icodes, Double_t *xyz, Int_t np,
    TAttFill::Modify();
    gPad->PaintFillArea(np, x, y);
    if (fMesh) {
+      SetFillStyle(0);
+      SetFillColor(fEdgeColor[fEdgeIdx]);
+      TAttFill::Modify();
+      gPad->PaintFillArea(np, x, y);
       SetLineColor(fEdgeColor[fEdgeIdx]);
       SetLineStyle(fEdgeStyle[fEdgeIdx]);
       SetLineWidth(fEdgeWidth[fEdgeIdx]);
@@ -661,6 +671,13 @@ void TPainter3dAlgorithms::DrawFaceMove1(Int_t *icodes, Double_t *xyz, Int_t np,
 
    //          D R A W   L E V E L   L I N E S
    SetLineStyle(3);
+   if (icodes[3]==0) {  /// front & back boxes
+      SetLineColor(1);
+      SetLineWidth(1);
+   } else {
+      SetLineColor(fEdgeColor[fEdgeIdx]);
+      SetLineWidth(fEdgeWidth[fEdgeIdx]);
+   }
    TAttLine::Modify();
    for (il = 1; il <= fNlines; ++il) {
       FindVisibleDraw(&fPlines[(2*il + 1)*3 - 9], &fPlines[(2*il + 2)*3 - 9]);
@@ -678,7 +695,15 @@ void TPainter3dAlgorithms::DrawFaceMove1(Int_t *icodes, Double_t *xyz, Int_t np,
    }
 
    //          D R A W   F A C E
-   SetLineStyle(1);
+   if (icodes[3]==0) {  /// front & back boxes
+      SetLineColor(1);
+      SetLineStyle(1);
+      SetLineWidth(1);
+   } else {
+      SetLineColor(fEdgeColor[fEdgeIdx]);
+      SetLineStyle(fEdgeStyle[fEdgeIdx]);
+      SetLineWidth(fEdgeWidth[fEdgeIdx]);
+   }
    TAttLine::Modify();
    for (i = 1; i <= np; ++i) {
       i1 = i;
@@ -756,6 +781,15 @@ void TPainter3dAlgorithms::DrawFaceMove3(Int_t *icodes, Double_t *xyz, Int_t np,
    FindLevelLines(np, p3, &tt[1]);
 
    // Draw level lines
+   if (icodes[3]==0) {  /// front and back boxes
+      SetLineColor(1);
+      SetLineStyle(1);
+      SetLineWidth(1);
+   } else {
+      SetLineColor(fEdgeColor[fEdgeIdx]);
+      SetLineStyle(fEdgeStyle[fEdgeIdx]);
+      SetLineWidth(fEdgeWidth[fEdgeIdx]);
+   }
    TAttLine::Modify();
    for (il = 1; il <= fNlines; ++il) {
       FindVisibleDraw(&fPlines[(2*il + 1)*3 - 9], &fPlines[(2*il + 2)*3 - 9]);
@@ -827,7 +861,7 @@ void TPainter3dAlgorithms::DrawFaceMove2(Int_t *icodes, Double_t *xyz, Int_t np,
    }
 
    //          D R A W   F A C E
-   if (icodes[3]==0) {  /// front box
+   if (icodes[3]==0) {  /// front & back boxes
       SetLineColor(1);
       SetLineStyle(1);
       SetLineWidth(1);
@@ -854,9 +888,6 @@ void TPainter3dAlgorithms::DrawFaceMove2(Int_t *icodes, Double_t *xyz, Int_t np,
          gPad->PaintPolyLine(2, x, y);
       }
    }
-   SetLineColor(1);
-   SetLineStyle(1);
-   SetLineWidth(1);
 
    //          M O D I F Y    S C R E E N
    for (i = 1; i <= np; ++i) {
@@ -919,6 +950,13 @@ void TPainter3dAlgorithms::DrawFaceRaster1(Int_t *icodes, Double_t *xyz, Int_t n
 
    //          D R A W   L E V E L   L I N E S
    SetLineStyle(3);
+   if (icodes[3]==0) {  /// front & back boxes
+      SetLineColor(1);
+      SetLineWidth(1);
+   } else {
+      SetLineColor(fEdgeColor[fEdgeIdx]);
+      SetLineWidth(fEdgeWidth[fEdgeIdx]);
+   }
    TAttLine::Modify();
    for (il = 1; il <= fNlines; ++il) {
       view->WCtoNDC(&fPlines[(2*il + 1)*3 - 9], p1);
@@ -936,7 +974,15 @@ void TPainter3dAlgorithms::DrawFaceRaster1(Int_t *icodes, Double_t *xyz, Int_t n
    }
 
    //          D R A W   F A C E
-   SetLineStyle(1);
+   if (icodes[3]==0) {  /// front & back boxes
+      SetLineColor(1);
+      SetLineStyle(1);
+      SetLineWidth(1);
+   } else {
+      SetLineColor(fEdgeColor[fEdgeIdx]);
+      SetLineStyle(fEdgeStyle[fEdgeIdx]);
+      SetLineWidth(fEdgeWidth[fEdgeIdx]);
+   }
    TAttLine::Modify();
    for (i = 1; i <= np; ++i) {
       if (iface[i] < 0) continue;
@@ -981,7 +1027,7 @@ void TPainter3dAlgorithms::DrawFaceRaster2(Int_t *icodes, Double_t *xyz, Int_t n
    //                       (not used in this routine)
 
    Double_t xdel, ydel;
-   Int_t i, k, icol, i1, i2, it;
+   Int_t i, k, i1, i2, it;
    Double_t p[3], x[2], y[2];
    Double_t pp[24]        /* was [2][12] */;
    TView *view = 0;
@@ -1005,9 +1051,9 @@ void TPainter3dAlgorithms::DrawFaceRaster2(Int_t *icodes, Double_t *xyz, Int_t n
    }
 
    //          D R A W   F A C E
-   icol = icodes[3];
-   if (icol) SetLineColor(fColorMain[icol - 1]);
-   else      SetLineColor(1);
+   SetLineColor(fEdgeColor[fEdgeIdx]);
+   SetLineStyle(fEdgeStyle[fEdgeIdx]);
+   SetLineWidth(fEdgeWidth[fEdgeIdx]);
    TAttLine::Modify();
    for (i = 1; i <= np; ++i) {
       if (iface[i] < 0) continue;
@@ -2367,6 +2413,7 @@ void TPainter3dAlgorithms::LegoCartesian(Double_t ang, Int_t nx, Int_t ny, const
    Double_t xyz[24];   // was [3][8]
    Double_t *tn = 0;
    TView *view = 0;
+   Int_t firstStackNumberDrawn=-1 ;  /// necessary to compute fColorBottom when the 0 option is set and when the stack is seen from below (bottomview, theta<0.)
 
    sina = TMath::Sin(ang*kRad);
    cosa = TMath::Cos(ang*kRad);
@@ -2429,7 +2476,6 @@ void TPainter3dAlgorithms::LegoCartesian(Double_t ang, Int_t nx, Int_t ny, const
 
    //          D R A W   S T A C K   O F   L E G O - P L O T S
    THistPainter *painter = (THistPainter*)gCurrentHist->GetPainter();
-   Int_t firstStackNumberDrawn=-1 ;  /// necessary to compute fColorBottom when the 0 option is set and when the stack is seen from below (bottomview, theta<0.)
    for (iy = iy1; incry < 0 ? iy >= iy2 : iy <= iy2; iy += incry) {
       for (ix = ix1; incrx < 0 ? ix >= ix2 : ix <= ix2; ix += incrx) {
          if (!painter->IsInside(ix,iy)) continue;
@@ -2571,6 +2617,7 @@ void TPainter3dAlgorithms::LegoPolar(Int_t iordr, Int_t na, Int_t nb, const char
    Double_t xyz[24];     // was [3][8]
    ia = ib = 0;
    TView *view = 0;
+   Int_t firstStackNumberDrawn=-1 ;  /// necessary to compute fColorBottom when the 0 option is set and when the stack is seen from below (bottomview, theta<0.)
 
    if (gPad) view = gPad->GetView();
    if (!view) {
@@ -2667,6 +2714,7 @@ L100:
          xyz[(j + 4)*3 - 2] = xyz[j*3 - 2];
       }
    //      D R A W   S T A C K
+      firstStackNumberDrawn=-1 ;
       for (iv = 1; iv < nv; ++iv) {
          for (i = 1; i <= 4; ++i) {
             xyz[i*3 - 1] = v[iv - 1];
@@ -2690,8 +2738,10 @@ L100:
             tface[2] = tt[k2 + ((iv + 1) << 2) - 5];
             tface[3] = tt[k1 + ((iv + 1) << 2) - 5];
             icodes[3] = i;
+            fEdgeIdx = iv-1 ;
             (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
          }
+         if ( firstStackNumberDrawn==-1 ) firstStackNumberDrawn = fEdgeIdx;
       }
    //         D R A W   B O T T O M   F A C E
       if (ivis[4] != 0) {
@@ -2702,6 +2752,11 @@ L100:
             iface[i - 1] = 5 - i;
             tface[i - 1] = tt[5 - i - 1];
          }
+         if (!Hoption.Zero) fEdgeIdx = 0;
+         else { 
+            fEdgeIdx = firstStackNumberDrawn ; 
+            fColorBottom = fColorMain[fEdgeIdx];
+         }
          (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
       }
    //         D R A W   T O P   F A C E
@@ -2713,9 +2768,15 @@ L100:
             tface[i - 1] = tt[i + (nv << 2) - 5];
          }
          Int_t cs = fColorTop;
-         if ( nv > 2 && (v[nv-1] == v[nv-2])) {
-            for (iv = nv-1; iv>2; iv--) {
-               if (v[nv-1] == v[iv-1]) fColorTop = fColorMain[iv-2];
+         if ( nv <= 3 ) fEdgeIdx = 0 ;  /// no stack or stack with only one histo
+         else {
+            if ( nv > 2 && (v[nv-1] == v[nv-2])) {
+               for (iv = nv-1; iv>2; iv--) {
+                  if (v[nv-1] == v[iv-1]) {
+                     fColorTop = fColorMain[iv-2];
+                     fEdgeIdx = iv-2 ;
+                  }
+               }
             }
          }
          (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
@@ -2793,6 +2854,7 @@ void TPainter3dAlgorithms::LegoCylindrical(Int_t iordr, Int_t na, Int_t nb, cons
    Double_t xyz[24];     // was [3][8]
    ia = ib = 0;
    TView *view = 0;
+   Int_t firstStackNumberDrawn=-1 ;  /// necessary to compute fColorBottom when the 0 option is set and when the stack is seen from below (bottomview, theta<0.)
 
    if (gPad) view = gPad->GetView();
    if (!view) {
@@ -2890,6 +2952,7 @@ L100:
          xyz[(j + 4)*3 - 1] = ab[jz + 2*i - 3];
       }
    //      D R A W   S T A C K
+      firstStackNumberDrawn=-1 ;
       for (iv = 1; iv < nv; ++iv) {
          for (i = 1; i <= 4; ++i) {
             xyz[i*3 - 3] = v[iv - 1]*cosphi[i - 1];
@@ -2913,8 +2976,10 @@ L100:
             tface[2] = tt[k2 + ((iv + 1) << 2) - 5];
             tface[3] = tt[k1 + ((iv + 1) << 2) - 5];
             icodes[3] = i;
+            fEdgeIdx = iv-1 ;
             (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
          }
+         if ( firstStackNumberDrawn==-1 ) firstStackNumberDrawn = fEdgeIdx;
       }
    //       D R A W   B O T T O M   F A C E
       if (ivis[4] != 0 && v[0] > 0) {
@@ -2926,6 +2991,11 @@ L100:
             iface[i - 1] = i;
             tface[i - 1] = tt[i - 1];
          }
+         if (!Hoption.Zero) fEdgeIdx = 0;
+         else { 
+            fEdgeIdx = firstStackNumberDrawn ; 
+            fColorBottom = fColorMain[fEdgeIdx];
+         }
          (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
       }
    //      D R A W   T O P   F A C E
@@ -2937,9 +3007,15 @@ L100:
             tface[i - 1] = tt[5 - i + (nv << 2) - 5];
          }
          Int_t cs = fColorTop;
-         if ( nv > 2 && (v[nv-1] == v[nv-2])) {
-            for (iv = nv-1; iv>2; iv--) {
-               if (v[nv-1] == v[iv-1]) fColorTop = fColorMain[iv-2];
+         if ( nv <= 3 ) fEdgeIdx = 0 ;  /// no stack or stack with only one histo
+         else {
+            if ( nv > 2 && (v[nv-1] == v[nv-2])) {
+               for (iv = nv-1; iv>2; iv--) {
+                  if (v[nv-1] == v[iv-1]) {
+                     fColorTop = fColorMain[iv-2];
+                     fEdgeIdx = iv-2 ;
+                  }
+               }
             }
          }
          (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
@@ -3015,6 +3091,7 @@ void TPainter3dAlgorithms::LegoSpherical(Int_t ipsdr, Int_t iordr, Int_t na, Int
    Double_t phi1, phi2;
    ia = ib = 0;
    TView *view = 0;
+   Int_t firstStackNumberDrawn=-1 ;  /// necessary to compute fColorBottom when the 0 option is set and when the stack is seen from below (bottomview, theta<0.)
 
    if (gPad) view = gPad->GetView();
    if (!view) {
@@ -3143,6 +3220,7 @@ L200:
       cosphi[j - 1] = TMath::Cos(kRad*ab[jphi + 2*i - 3]);
       sinphi[j - 1] = TMath::Sin(kRad*ab[jphi + 2*i - 3]);
    }
+   firstStackNumberDrawn=-1 ;
    for (iv = 1; iv < nv; ++iv) {
       if (ipsdr == 1) {
          for (i = 1; i <= 4; ++i) {
@@ -3179,8 +3257,10 @@ L200:
          tface[2] = tt[k2 + ((iv + 1) << 2) - 5];
          tface[3] = tt[k1 + ((iv + 1) << 2) - 5];
          icodes[3] = i;
+         fEdgeIdx = iv-1 ;
          (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
       }
+      if ( firstStackNumberDrawn==-1 ) firstStackNumberDrawn = fEdgeIdx;
    }
    //      D R A W   B O T T O M   F A C E
    if (ivis[4] != 0 && v[0] > 0) {
@@ -3199,6 +3279,11 @@ L200:
          iface[i - 1] = 5 - i;
          tface[i - 1] = tt[5 - i - 1];
       }
+      if (!Hoption.Zero) fEdgeIdx = 0;
+      else { 
+         fEdgeIdx = firstStackNumberDrawn ; 
+         fColorBottom = fColorMain[fEdgeIdx];
+      }
       (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
    }
    //      D R A W   T O P   F A C E
@@ -3210,9 +3295,15 @@ L200:
          tface[i - 1] = tt[i + 4 + 2*nv - 5];
       }
       Int_t cs = fColorTop;
-      if ( nv > 2 && (v[nv-1] == v[nv-2])) {
-         for (iv = nv-1; iv>2; iv--) {
-            if (v[nv-1] == v[iv-1]) fColorTop = fColorMain[iv-2];
+      if ( nv <= 3 ) fEdgeIdx = 0 ;  /// no stack or stack with only one histo
+      else {
+         if ( nv > 2 && (v[nv-1] == v[nv-2])) {
+            for (iv = nv-1; iv>2; iv--) {
+               if (v[nv-1] == v[iv-1]) {
+                  fColorTop = fColorMain[iv-2];
+                  fEdgeIdx = iv-2 ;
+               }
+            }
          }
       }
       (this->*fDrawFace)(icodes, xyz, 4, iface, tface);
@@ -3719,7 +3810,7 @@ void TPainter3dAlgorithms::SurfaceCartesian(Double_t ang, Int_t nx, Int_t ny, co
    Double_t cosa, sina, f[12]        /* was [3][4] */;
    Int_t i, incrx, incry, i1, ix, iy;
    Double_t tt[4];
-   Int_t icodes[2], ix1, iy1, ix2, iy2;
+   Int_t icodes[3], ix1, iy1, ix2, iy2;  /// was icode[2]. One element more to differentiate front & back boxes from data
    Double_t xyz[12]        /* was [3][4] */;
    Double_t *tn;
 
@@ -3755,6 +3846,8 @@ void TPainter3dAlgorithms::SurfaceCartesian(Double_t ang, Int_t nx, Int_t ny, co
    iy2 = ny - iy1 + 1;
 
    //          D R A W   S U R F A C E
+   icodes[2] = -1;   /// -1 for data, 0 for front a back boxes
+   fEdgeIdx = 0;   /// constant since stacks are not (yet?) handled for surfaces
    THistPainter *painter = (THistPainter*)gCurrentHist->GetPainter();
    for (iy = iy1; incry < 0 ? iy >= iy2 : iy <= iy2; iy += incry) {
       for (ix = ix1; incrx < 0 ? ix >= ix2 : ix <= ix2; ix += incrx) {
@@ -3950,7 +4043,7 @@ void TPainter3dAlgorithms::SurfacePolar(Int_t iordr, Int_t na, Int_t nb, const c
    Double_t f[12]        /* was [3][4] */;
    Int_t i, j, incrr, ir1, ir2;
    Double_t z;
-   Int_t ia, ib, ir, jr, nr, icodes[2];
+   Int_t ia, ib, ir, jr, nr, icodes[3];  /// was icode[2]. One element more to differentiate front & back boxes from data
    Double_t tt[4];
    Double_t phi, ttt[4], xyz[12]        /* was [3][4] */;
    ia = ib = 0;
@@ -3989,6 +4082,8 @@ void TPainter3dAlgorithms::SurfacePolar(Int_t iordr, Int_t na, Int_t nb, const c
    view->FindPhiSectors(iopt, kphi, fAphi, iphi1, iphi2);
 
    //       D R A W   S U R F A C E
+   icodes[2] = -1;   /// -1 for data, 0 for front a back boxes
+   fEdgeIdx = 0;   /// constant since stacks are not (yet?) handled for surfaces
    incr = 1;
    iphi = iphi1;
 L100:
@@ -4085,7 +4180,7 @@ void TPainter3dAlgorithms::SurfaceCylindrical(Int_t iordr, Int_t na, Int_t nb, c
 
    Int_t iphi, jphi, kphi, incr, nphi, iopt, iphi1, iphi2;
    Int_t i, j, incrz, nz, iz1, iz2;
-   Int_t ia, ib, iz, jz, icodes[2];
+   Int_t ia, ib, iz, jz, icodes[3];  /// was icode[2]. One element more to differentiate front & back boxes from data
    Double_t f[12]        /* was [3][4] */;
    Double_t z;
    Double_t tt[4];
@@ -4143,6 +4238,8 @@ void TPainter3dAlgorithms::SurfaceCylindrical(Int_t iordr, Int_t na, Int_t nb, c
    iz2 = nz - iz1 + 1;
 
    //       D R A W   S U R F A C E
+   icodes[2] = -1;   /// -1 for data, 0 for front a back boxes
+   fEdgeIdx = 0;   /// constant since stacks are not (yet?) handled for surfaces
    incr = 1;
    iphi = iphi1;
 L100:
@@ -4217,7 +4314,7 @@ void TPainter3dAlgorithms::SurfaceSpherical(Int_t ipsdr, Int_t iordr, Int_t na,
 
    Int_t iphi, jphi, kphi, incr, nphi, iopt, iphi1, iphi2;
    Int_t i, j, incrth, ith, jth, kth, nth, mth, ith1, ith2;
-   Int_t ia, ib, icodes[2];
+   Int_t ia, ib, icodes[3];  /// was icode[2]. One element more to differentiate front & back boxes from data
    Double_t f[12]        /* was [3][4] */;
    Double_t tt[4];
    Double_t phi;
@@ -4284,6 +4381,8 @@ void TPainter3dAlgorithms::SurfaceSpherical(Int_t ipsdr, Int_t iordr, Int_t na,
    }
 
    //       D R A W   S U R F A C E
+   icodes[2] = -1;   /// -1 for data, 0 for front a back boxes
+   fEdgeIdx = 0;   /// constant since stacks are not (yet?) handled for surfaces
    kth  = nth;
    incr = 1;
    iphi = iphi1;
