Add missing commits to master

Rebased 1.3.x changes on top of 1.2.5.Final.