more work on main_loop in recv.c