Finished implementation of ROI merging across patches. Doesn't run right though, looks like there's an indexing error somewhere.