Might have fixed the circular buffer problem. Lots of debug code to clean up.