Made directory parameter more forgiving