Fix directory symlinks

@fjakobs For the problem you were having. Only the second commit is relevant.