bugfixes and client changes from downstream

Reviewers: usmanm, marcua

Reviewed By: usmanm

Differential Revision: http://phabricator.locu.com/D2915