re-factored some file system access