First solid version of adaptive histogramming code
Near final histogramming.  Still needs testing and thought for repeated values.