Message send and receive functions edited (still need debugging)