Better byte swapping in ringbuffer and fixed logging.