switch to more robust contiguous-regions strategy; and many small fixes