Rearranged code slightly to make RefX listings more intelligible.