backports from master to 1.5 branch