I assume the limit percentage number goes into subparse->limitCount? If so, I don't see that documented. Or does this truly only store the count?
The remainder of the code seems to make sense. I attached a patch with a few minor changes in the comments. I need to go back to my notes and see if I covered all the testing I had thought of, I should get to that later this week.