Fix buffer flush