How can I improve my standing with the Pope?
According to this GameFaqs strategy guide, the following works for maintaining a good relationship with the Pope:
"Doing missions for the Pope, not fighting other Catholics, and giving the Pope large sums of money are good ways to maintain a healthy relationship with him."
The strategy guide also mentions assassinating the Pope to try to get someone more favorable to you to be the Pope and bribery for when you get excommunicated.
Usually, replace him with a friendly pope. Barring that, large sums of money.
Yes, the number of churches and priests matter. If your relationship with the Pope is at rock bottom, you can send him gifts, then ally with him, etc. Crusades in which you where active also count for your standing with the Pope.