Client state

Refactoring of <client-state> functionality. Removing of <client-info>.
Many other tweaks and improvements.

Please review and test.