am a07d37b7: Cherry-pick bug fixes from master.

Merge commit 'a07d37b79300e76da5f21f532578fcd686a74b16' into gingerbread

* commit 'a07d37b79300e76da5f21f532578fcd686a74b16':
  Cherry-pick bug fixes from master.