Fix buffer number detection