Originally taken from 1.31 version