Split directory functions into own file.