Changes to ring buffer code