fix some overflows in the histogram