I've found the problem.
I removed the inline hint on all the functions because it was interfering with the debugging of the recent problems, and this has slowed everything down by about 50-100%.
What I'm going to do is make all the inline hints switchable with a {$define}, then they can be turned off/on easily.
This will take a day or two, because it appears that for the hint to be acted upon by the compiler, all instances of the function header must have the inline hint, not just the final one with the code inside. Also, I don't want to put inline on all the functions, just the ones where it will matter, e.g. the many "wrapper" functions with minimal code that just call another main function to do the work.