adding the cyclyc buffer implementation and refactoring the raw code