Added timeout choice when sending and receiving
Removed several memory leaks
Debug