Fix buffer counting