fixed the binning and the overflow logic. also some cleanup