backports from my own branch