relay: cleanup code