This is needed for pivot tables, split out from that branch so any further changes to filename handling will be easier in master.