Still a bug remains. Inifinte loop when relative path of directory is used.