fix CRM-12004
fix CRM-12005
sync with upstream master
Merge pull request #14 from dlobo/CRM-12005

Fix for CRM-12005 and CRM-12004
Merge branch 'master' of git://github.com/civicrm/civicrm-core into CRM-12008