Squashed some improvements from CodeAurora

Change-Id: I949b078410c808de13f45f49b5fee44265e1b32c