fixed issue with bad byte offset calculations