backport 1.7 -> 1.6