Fix endless looping in circularbuffer