Code for receiver side. Not tested fully and handling of deliveries is
incomplete.
Modified the test case to compile with the new changes.