Fixed buffer flush function