Implementation of relay. Ready for testing. Might have to change a few things.