Fix ringbuffer bug
Add some debugging info