Relay: initial import from Limnoria (forked by request)