Fix buffer accounting