I guarantee that piece of code has a comment like
/* This should never happen */
if (waypoints.matchcount > 2) { /* This should never happen */
if (waypoints.matchcount > 2) { waypoint = waypointsMatches[0]
Without even mentioning that waypointsMatches might have multiple elements.This is why I always consider [0] to be a code smell. It doesn't have a name afaik, but it should.
I'm sure there'd be a better way to handle this, but it sounds to me like the system failed in a graceful way and acted as specified.