Backport #15546 to 2014.7 branch

This was a better fix than my recent fix.