Added sending and receiving functions that take custom functions for sending/receiving (untested).