Fix directory detection.