relay: more refactoring and fixing of interfaces