Misc fixes as passed to us

(cherry picked from commit 929d1854e9e90c3e3d470302d55914f4cef3b89c)