Happy New Year 2018 Backport of r1820080 from APR trunk resp. r1820085 and r1820086 from 1.7.x resp. r1820087 from 1.6.x.