Moved some functions to directories.py