Added binning and reading code