In #86 Alistair mentions:
@kenkeys I think we have a bit of a problem with these potential integer underflows I created with all the remain - nread and similar subtractions. I fixed a couple here, but probably we need to fix these all across the library :(