MDS reordering: matches and better remote rebuild

The mds_reorder call was not preserving matches.
Also, the algorithm being used for remotes was
strange. Replace it with the more general
algorithm from apf::convert, use it for both nets.

This is a serious core change, rerun all tests.