Port fix from cc679c76a53975f66ae12cbdfc6786c9609656d0