Small tweak to ringbuffer code, plus docstrings!