Refactor file utilities