fixed some issues with buffer