Feature/refactor client hello 2

The same as #5980, but better organized.