Fixed receive segmentation fault because of multiple messages from daemon at once and fixed some memory leaks.
Merge pull request #32 from sweetpi/master

Fixed receive segmentation fault because of multiple messages from daemon at once