cleanup, added inline ring buffer functions