Ported changes from 1.4.