Fix for JENKINS-16669 and JENKINS-16617.