Glad you found a better way of fixing this!
I don’t remember the exact details of this code, just I wasn’t super confident of my solution, but also didn’t want to risk messing up a core class.
Here is my original post with a breakdown and an example for more context if anyone wants to read up more: BatchNode and IndexOutOfBoundsException