Reworked buffer handling.