MT#5073 sync with 3.0 branch.

This was a mess. I should sleep more and drink less RedBull.