Yes, converting from my byte-based offsets to INT-based offsets introduced some confusion. I could have better done it by writing a program to convert them.
In particular, the maxsize of strings may be off by one.