The example you gave did indeed break the code. I've added your example to test_internals.py and
am handling this case by sorting the blocks according to their `ref_locs`.