Circular buffer functionality.