Added directory; added naive cycle detection algorithm