Added more buffer functionality. Cleaned up a little.