Rework ringbuffer class, add tests
More ringbuffer work
Adjust main code to ringbuffer changes
Fix last commit