Fixed ring buffer bugs