Modify directory-access functions

- Make functions more generic
- Add documentation for functions