Better support usernames with spaces in them

Change-Id: I0b9e077789e560a7ca4822f80cfe206f41579662
(cherry picked from commit b968eeb43e87f7d35397187a31c1c237d925c137)