Clean up console redirection code: use a struct and typedef the Flush function.