Passing unsigned ints everywhere is painful, and will cause some headache later when we'll want to integrate better with struct ist which already uses size_t. Let's switch buffers to use size_t instead.