Some refactoring of the file download service.