Merged upstream.

Merged upstream improvements.