Add to_socket, send_all, recv_all; clean up some comments