Use .dirname instead of deprecated .directory