refactor ring buffer to allow dumping of the buffer