Dirname crash fix