Switch lengths to uint64_t to allow large memory allocations