Well, maybe I am hallucinating or something, but what's to stop refInfo.d[] from being less than 1...?

m->initd[(ri->d[0]/10000) - 1][(ri->d[1]/10000)] = value;

Is this valid?