Factor common code into idp_utils
Factor out GetPathAndName and simplify a bit