Refactor file system interactions