diff --git a/hist/src/TH1.cxx b/hist/src/TH1.cxx
index ed2229da56c21fbed8a1cba9e029f33866d65875..7564f0a7e9e163165f43c73e31631e9cf19095bf 100644
--- a/hist/src/TH1.cxx
+++ b/hist/src/TH1.cxx
@@ -1,4 +1,4 @@
-// @(#)root/hist:$Name:  $:$Id: TH1.cxx,v 1.216 2005/01/13 20:07:46 brun Exp $
+// @(#)root/hist:$Name:  $:$Id: TH1.cxx,v 1.217 2005/01/20 21:58:44 brun Exp $
 // Author: Rene Brun   26/12/94
 
 /*************************************************************************
@@ -3498,7 +3498,8 @@ Int_t TH1::Merge(TCollection *list)
 //
 // IMPORTANT remark. The axis x may have different number
 // of bins and different limits, BUT the largest bin width must be
-// a multiple of the smallest bin width.
+// a multiple of the smallest bin width and the upper limit must also 
+// be a multiple of the bin width.
 // Example:
 // void atest() {
 //    TH1F *h1 = new TH1F("h1","h1",110,-110,0);
@@ -3533,15 +3534,14 @@ Int_t TH1::Merge(TCollection *list)
    Stat_t stats[kNstat], totstats[kNstat];
    TH1 *h, *hclone=0;
    Int_t i, nentries=(Int_t)fEntries;
+   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
+   GetStats(totstats);
    TList inlist;
    if (nentries > 0) {
-      nentries = 0;
       hclone = (TH1*)Clone("FirstClone");
       Reset();
       inlist.Add(hclone);
    }
-   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
-   GetStats(totstats);
    Bool_t same = kTRUE;
 
    THashList allLabels;
@@ -3603,8 +3603,11 @@ Int_t TH1::Merge(TCollection *list)
    if (!same) {
       if (allHaveLabels)
          nbix=allLabels.GetSize();
-      else
-         nbix = (Int_t) ((xmax-xmin)/bwix +0.1); while(nbix > 100) nbix /= 2;
+      else {
+         nbix = (Int_t) ((xmax-xmin)/bwix +0.5); 
+         //while (nbix>fXaxis.GetNbins()) {nbix /= 2; bwix *= 2; }
+         xmax = xmin + nbix*bwix;
+      } 
       SetBins(nbix,xmin,xmax);
    }
 
@@ -3956,7 +3959,7 @@ TH1 *TH1::Rebin(Int_t ngroup, const char*newname)
       hnew->SetName(newname);
    }
 
-   // change axis specs and rebuild bin contents array
+   // change axis specs and rebuild bin contents array::RebinAx
    if(newbins*ngroup != nbins) {
       xmax = fXaxis.GetBinUpEdge(newbins*ngroup);
       hnew->fTsumw = 0; //stats must be reset because top bins will be moved to overflow bin
@@ -4054,7 +4057,7 @@ void TH1::RebinAxis(Axis_t x, const char *ax)
          if (ntimes > 64) break;
          range *= 2;
          if (x < cxmax-range) continue;
-         xmin = cxmin - range/4;
+         xmin = cxmin - range/2;
          xmax = xmin + range;
          if (x < xmin) {
             xmin = cxmax - range;
diff --git a/hist/src/TH2.cxx b/hist/src/TH2.cxx
index ff04a9bd33cd611e33af4597ae55223de411bb62..115f3111aedae48e0c8ac87eed2929613515dd09 100644
--- a/hist/src/TH2.cxx
+++ b/hist/src/TH2.cxx
@@ -1,4 +1,4 @@
-// @(#)root/hist:$Name:  $:$Id: TH2.cxx,v 1.62 2004/12/21 13:52:52 brun Exp $
+// @(#)root/hist:$Name:  $:$Id: TH2.cxx,v 1.63 2005/01/20 21:58:44 brun Exp $
 // Author: Rene Brun   26/12/94
 
 /*************************************************************************
@@ -1282,7 +1282,8 @@ Int_t TH2::Merge(TCollection *list)
    //
    //IMPORTANT remark. The 2 axis x and y may have different number
    //of bins and different limits, BUT the largest bin width must be
-   //a multiple of the smallest bin width.
+   //a multiple of the smallest bin width and the upper limit must also 
+   //be a multiple of the bin width.
 
    if (!list) return 0;
    TIter next(list);
@@ -1301,15 +1302,14 @@ Int_t TH2::Merge(TCollection *list)
    Stat_t stats[kNstat], totstats[kNstat];
    TH2 *h, *hclone=0;
    Int_t i, nentries=(Int_t)fEntries;
+   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
+   GetStats(totstats);
    TList inlist;
    if (nentries > 0) {
-      nentries = 0;
       hclone = (TH2*)Clone("FirstClone");
       Reset();
       inlist.Add(hclone);
    }
-   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
-   GetStats(totstats);
    Bool_t same = kTRUE;
    while ((h=(TH2*)next())) {
       if (!h->InheritsFrom(TH2::Class())) {
@@ -1343,8 +1343,10 @@ Int_t TH2::Merge(TCollection *list)
 
    //  if different binning compute best binning
    if (!same) {
-      nbix = (Int_t) ((xmax-xmin)/bwix +0.1); while(nbix > 100) nbix /= 2;
-      nbiy = (Int_t) ((ymax-ymin)/bwiy +0.1); while(nbiy > 100) nbiy /= 2;
+      nbix = (Int_t) ((xmax-xmin)/bwix +0.5); // while(nbix > 100) nbix /= 2;
+      nbiy = (Int_t) ((ymax-ymin)/bwiy +0.5); // while(nbiy > 100) nbiy /= 2;
+      xmax = xmin + nbix*bwix;
+      ymax = ymin + nbiy*bwiy;
       SetBins(nbix,xmin,xmax,nbiy,ymin,ymax);
    }
 
diff --git a/hist/src/TH3.cxx b/hist/src/TH3.cxx
index 191c2b90362e857f0111343b7976153874e24fa7..eccb7de1c2575958ecad7f800fa62b6b28a02538 100644
--- a/hist/src/TH3.cxx
+++ b/hist/src/TH3.cxx
@@ -1,4 +1,4 @@
-// @(#)root/hist:$Name:  $:$Id: TH3.cxx,v 1.54 2005/01/16 16:08:59 brun Exp $
+// @(#)root/hist:$Name:  $:$Id: TH3.cxx,v 1.55 2005/01/20 21:58:44 brun Exp $
 // Author: Rene Brun   27/10/95
 
 /*************************************************************************
@@ -1199,7 +1199,8 @@ Int_t TH3::Merge(TCollection *list)
    //
    //IMPORTANT remark. The 3 axis x,y and z may have different number
    //of bins and different limits, BUT the largest bin width must be
-   //a multiple of the smallest bin width.
+   //a multiple of the smallest bin width and the upper limit must also 
+   //be a multiple of the bin width.
    
    if (!list) return 0;
    TIter next(list);
@@ -1222,15 +1223,14 @@ Int_t TH3::Merge(TCollection *list)
    Stat_t stats[kNstat], totstats[kNstat];
    TH3 *h, *hclone=0;
    Int_t i, nentries=(Int_t)fEntries;
+   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
+   GetStats(totstats);
    TList inlist;
    if (nentries > 0) {
-      nentries = 0;
       hclone = (TH3*)Clone("FirstClone");
       Reset();
       inlist.Add(hclone);
    }
-   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
-   GetStats(totstats);
    Bool_t same = kTRUE;
    while ((h=(TH3*)next())) {     
       if (!h->InheritsFrom(TH3::Class())) {
@@ -1272,9 +1272,12 @@ Int_t TH3::Merge(TCollection *list)
    
    //  if different binning compute best binning
    if (!same) {
-      nbix = (Int_t) ((xmax-xmin)/bwix +0.1); while(nbix > 100) nbix /= 2;
-      nbiy = (Int_t) ((ymax-ymin)/bwiy +0.1); while(nbiy > 100) nbiy /= 2;
-      nbiz = (Int_t) ((zmax-zmin)/bwiz +0.1); while(nbiz > 100) nbiz /= 2;
+      nbix = (Int_t) ((xmax-xmin)/bwix +0.1); // while(nbix > 100) nbix /= 2;
+      nbiy = (Int_t) ((ymax-ymin)/bwiy +0.1); // while(nbiy > 100) nbiy /= 2;
+      nbiz = (Int_t) ((zmax-zmin)/bwiz +0.1); // while(nbiz > 100) nbiz /= 2;
+      xmax = xmin + nbix*bwix;
+      ymax = ymin + nbiy*bwiy;
+      zmax = zmin + nbiz*bwiz;
       SetBins(nbix,xmin,xmax,nbiy,ymin,ymax,nbiz,zmin,zmax);
    }
    
diff --git a/hist/src/TProfile.cxx b/hist/src/TProfile.cxx
index f18a7282cbe58ffe1c91554af2a4223d8ea7d250..b62724a0d568cd412a1e9e105bb62b46601e1fd3 100644
--- a/hist/src/TProfile.cxx
+++ b/hist/src/TProfile.cxx
@@ -1,4 +1,4 @@
-// @(#)root/hist:$Name:  $:$Id: TProfile.cxx,v 1.51 2004/12/20 10:01:41 brun Exp $
+// @(#)root/hist:$Name:  $:$Id: TProfile.cxx,v 1.52 2005/01/20 21:58:44 brun Exp $
 // Author: Rene Brun   29/09/95
 
 /*************************************************************************
@@ -15,6 +15,7 @@
 #include "THLimitsFinder.h"
 #include "Riostream.h"
 
+const Int_t kNstat = 11;
 Bool_t TProfile::fgApproximate = kFALSE;
 
 ClassImp(TProfile)
@@ -1169,7 +1170,8 @@ Int_t TProfile::Merge(TCollection *list)
    //
    //IMPORTANT remark. The axis x may have different number
    //of bins and different limits, BUT the largest bin width must be
-   //a multiple of the smallest bin width.
+   //a multiple of the smallest bin width and the upper limit must also 
+   //be a multiple of the bin width.
 
    if (!list) return 0;
    TIter next(list);
@@ -1180,11 +1182,13 @@ Int_t TProfile::Merge(TCollection *list)
    Double_t bwix  = fXaxis.GetBinWidth(1);
    Int_t    nbix  = fXaxis.GetNbins();
 
+   Stat_t stats[kNstat], totstats[kNstat];
    TProfile *h, *hclone=0;
-   Int_t nentries=(Int_t)fEntries;
+   Int_t i, nentries=(Int_t)fEntries;
+   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
+   GetStats(totstats);
    TList inlist;
    if (nentries > 0) {
-      nentries = 0;
       hclone = (TProfile*)Clone("FirstClone");
       Reset();
       inlist.Add(hclone);
@@ -1197,6 +1201,8 @@ Int_t TProfile::Merge(TCollection *list)
       }
       inlist.Add(h);
       //import statistics
+      h->GetStats(stats);
+      for (i=0;i<kNstat;i++) totstats[i] += stats[i];
       nentries += (Int_t)h->GetEntries();
 
       // find min/max of the axes
@@ -1213,7 +1219,9 @@ Int_t TProfile::Merge(TCollection *list)
 
    //  if different binning compute best binning
    if (!same) {
-      nbix = (Int_t) ((xmax-xmin)/bwix +0.1); while(nbix > fXaxis.GetNbins()) nbix /= 2;
+      nbix = (Int_t) ((xmax-xmin)/bwix +0.5); 
+      //while(nbix > fXaxis.GetNbins()) nbix /= 2;
+      xmax = xmin + nbix*bwix;
       SetBins(nbix,xmin,xmax);
    }
 
@@ -1235,6 +1243,8 @@ Int_t TProfile::Merge(TCollection *list)
       fTsumwx2 += h->fTsumwx2;
       fTsumwy  += h->fTsumwy;
    }
+   PutStats(totstats);
+   SetEntries(nentries);
    if (hclone) delete hclone;
    return nentries;
 }
diff --git a/hist/src/TProfile2D.cxx b/hist/src/TProfile2D.cxx
index a84fa7379b438f624f80219c033854a169a047c7..daa830e70b8312dd9c587e4ab8368d4b3bc35312 100644
--- a/hist/src/TProfile2D.cxx
+++ b/hist/src/TProfile2D.cxx
@@ -1,4 +1,4 @@
-// @(#)root/hist:$Name:  $:$Id: TProfile2D.cxx,v 1.27 2004/12/20 10:01:41 brun Exp $
+// @(#)root/hist:$Name:  $:$Id: TProfile2D.cxx,v 1.28 2005/01/20 21:58:44 brun Exp $
 // Author: Rene Brun   16/04/2000
 
 /*************************************************************************
@@ -14,6 +14,7 @@
 #include "THLimitsFinder.h"
 #include "Riostream.h"
 
+const Int_t kNstat = 11;
 Bool_t TProfile2D::fgApproximate = kFALSE;
 
 ClassImp(TProfile2D)
@@ -1264,7 +1265,8 @@ Int_t TProfile2D::Merge(TCollection *list)
    //
    //IMPORTANT remark. The 2 axis x and y may have different number
    //of bins and different limits, BUT the largest bin width must be
-   //a multiple of the smallest bin width.
+   //a multiple of the smallest bin width and the upper limit must also 
+   //be a multiple of the bin width.
 
    if (!list) return 0;
    TIter next(list);
@@ -1279,11 +1281,13 @@ Int_t TProfile2D::Merge(TCollection *list)
    Int_t    nbix  = fXaxis.GetNbins();
    Int_t    nbiy  = fYaxis.GetNbins();
 
+   Stat_t stats[kNstat], totstats[kNstat];
    TProfile2D *h, *hclone=0;
-   Int_t nentries=(Int_t)fEntries;
+   Int_t i, nentries=(Int_t)fEntries;
+   for (i=0;i<kNstat;i++) {totstats[i] = stats[i] = 0;}
+   GetStats(totstats);
    TList inlist;
    if (nentries > 0) {
-      nentries = 0;
       hclone = (TProfile2D*)Clone("FirstClone");
       Reset();
       inlist.Add(hclone);
@@ -1296,6 +1300,8 @@ Int_t TProfile2D::Merge(TCollection *list)
       }
       inlist.Add(h);
       //import statistics
+      h->GetStats(stats);
+      for (i=0;i<kNstat;i++) totstats[i] += stats[i];
       nentries += (Int_t)h->GetEntries();
 
       // find min/max of the axes
@@ -1319,8 +1325,10 @@ Int_t TProfile2D::Merge(TCollection *list)
 
    //  if different binning compute best binning
    if (!same) {
-      nbix = (Int_t) ((xmax-xmin)/bwix +0.1); while(nbix > 100) nbix /= 2;
-      nbiy = (Int_t) ((ymax-ymin)/bwiy +0.1); while(nbiy > 100) nbiy /= 2;
+      nbix = (Int_t) ((xmax-xmin)/bwix +0.1); //while(nbix > 100) nbix /= 2;
+      nbiy = (Int_t) ((ymax-ymin)/bwiy +0.1); //while(nbiy > 100) nbiy /= 2;
+      xmax = xmin + nbix*bwix;
+      ymax = ymin + nbiy*bwiy;
       SetBins(nbix,xmin,xmax,nbiy,ymin,ymax);
    }
 
@@ -1352,6 +1360,8 @@ Int_t TProfile2D::Merge(TCollection *list)
       fTsumwz  += h->fTsumwz;
       fTsumwz2 += h->fTsumwz2;
   }
+   PutStats(totstats);
+   SetEntries(nentries);
    if (hclone) delete hclone;
 
    return nentries;