fixed bug where buffer offset was being reset to zero.