How did the catholic church generate so much money or revenue during the middle ages