Move awkwardly placed flush() function