Why was the church so important in medieval times