substr() takes a length, not an offset. Fixes #275