CRM-15250 and CRM-15232 fixes


https://issues.civicrm.org/jira/browse/CRM-15250