wait before sending the response; fix many bugs