New fix grad scan

Fix of the Hessian issue. 

The fix involves changing how some indexes are computed (for mitmot sequences). I've done a bit of math in my head and it feels right, but I'd like to have a second pair of eyes on that bit.