Fix directory detection