How was the church economically powerful during the middle ages