Minor bug fixes to the code that iterates over subsets of the data.