debugged some mistakes in ringbuffer