Refactor histogram and likelihood code, preparing for 2d histograms