Fixed directory lookup and redundant checks.