Backported changes from client project.
Backported fixes from client project.