When inserting with an invalid index, ensure we return the leg based on the fixed-up index, not the original one. Thanks to Matthias Götz for the catch!
The routing behaviour now happens entirely in Nasal,
using a delegate, and can be over-ridden or disable
by aircraft authors. Default behaviour should be
unchanged.