Ported patches from 1.4.x