CRM-13833 and CRM-13981 fixes