free dirname bug + minor