handshake fixes: respond with correct xid, support retry