copied fix from account_transfer branch.