Refactored code to make it easier to implement a buffer
More refactoring. Much better public interfaces for all classes