Fix a bug with buffering