Refactor FileUtils for thread safety.