Tidied up the relay code in preparation for additional examples