File fixes agg

aggregated 2 previous PRs #6578 and  #6570