Fixed second bug in finding the range of allowed ROI locations.