refactoring, commenting and generic filesystem api