Ring buffer fix buf.

ring buffer now works properly.