Squashed some improvements from CodeAurora"

This reverts commit c2477a68b3d5d43f7c97c3e2c8822b2f832ea39b.