Forward port of branch 7.0 up to bc2a52f