Refactor file name handling.