Refactor path derivation functions