some fixes brought over from the salesforce branch