CRM-12623 mgd and other misc fixes