Symlink directory loop detection

This fixes #153.