Calculate full histograms for better accuracy, fix off by a factor of 1/2 error in code offsets