fix buffering

optimize some methods