more clean up
added a way to precompute and compute histograms