Refactor service prefix derivation