relay: fix build and cleanup code