Fixed bug with buffer slicing