Port more API fixes from Petr's branch.
Merge bug26469
Merge remote-tracking branch 'upstream/master' into multi_authorization