Port 2.12.x changes

Ported all changes from 2.12.x branch to 3.0.x