Further work towards generic histogram code