Rearranged things a bit in preparation for segmented 2D map packing.