Cherry-pick 3 upstream fixes
am: 9888dce90e

Change-Id: I84c5911c20662c5e0b985905ed54edd64f1fb8d0