Fix memory errors. Fix tcp_recv.