fix bug in buffer cleanup