Improvements mostly related to client-server usage

Just wondering whether this can not end up in an infinite loop. What about some 'maxAttempts' variable check?