relay: more minor refactoring