Fix buffer flip issue