Have you considered using cursors? VFP cursors automatically span to disk, meaning you can forget about the resource problems to be expected from memory-resident collections, arrays or datasets. You can create thousands of VFP cursors if necessary- to store intermediate results or simplify nested processing. You can index your cursors on the fly after which you should be able to replace intensive loops with SQL queries that can be very quick against indexed tables or cursors.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us."
-- Shakespeare: Coriolanus, Act 1, scene 1