Refactored ring buffer

See #54