Remove memory leaks, wrapped tcp connection