fix some of-by-one woes and amend a struct (int64_t -> int)