Ported fixes from 1.4.2