Cleaned up the buffer interface and implementation.