Make the PING/PONG code more robust.