Added dynamic memory allocation to crypto connections.

Also fixed some possible bugs in Messenger.c
Fixed bug.