This bug was caused by the code not tolerating missing navaids / waypoints. Update logic so missing navaids degenerate to basic waypoints without problem. Also tolerate present, but empty, runway properties - don't throw an exception by looking up empty identifiers.
The Flight-plan leg data computation was omitting certain data for the final waypoint, which in turn made some of the route-manager data bogus when flying the final leg. Fill in some sensible values which we can compute.
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.