This is somewhat unrelated to this PR but...

It's probably worth pointing out that this (and the previous version of the code) will evaluate this function on each iteration of the loop.  Evaluating this could be factored out of the loop to improve efficiency.

It's probably also worth mentioning that there is (and still would be) a race between querying the number of instances and doing the Get call inside the loop.  In the future, if we can delete instances, this could fail.  The return code from WaypointInstGet() should be checked.