Added sub and sub-all dirs only if specified
Changed the behavior for empty sub entries, because we need the main path.