File operations refactor