Removed a possible double free, and added the message to hash table before sending