Changes to circular buffer code