Should fix double header bug when downloading a file. See #6807
Minor - code style changes.