relay: massive reorganization to improve consistency of Relay