Fixed bug where last slot of the buffer would never be used.