Fix for issue #12.
Refactored ringbuffer code. Put in its own branch while I sort out an audio bug