Reordered code, and fixed up histogram bins