Refactor file construction