fix for filename/dirname overlap bug