[lib/client]Restructure client-state into a flag-field, to make it more clear and avoid tricky race-conditions.