CRM-13227, CRM-14744: full fix
Merge pull request #4314 from cividesk/CRM-13227

CRM-13227, CRM-14744: full fix