Fix buffer bounds

Improper set of buffer bounds was leading to "slice bounds out of range" runtime error.