fyi: i think grain has some serious issues on reading some index of an array without checking last time i read the code. i would take a look at the code and tell you the details.
if higher layers of your code are not checking this, then it would ve easy to make it to crash...
maybe i opened a pr.