fixes for CRM-13056
Merge pull request #41 from kurund/CRM-13056

fixes for CRM-13056
patched CRM-13077
Merge pull request #43 from kurund/CRM-13077

patched CRM-13077