Fixed a few errors in buffer processing.