rework handling of file downloads