Rearranged the command and receive routines so they block when needed.