The Merinids subsidized numerous madrasahs in order to ensure the inclulcation of Sunnism and to check the rising tide of Sufism which was gnawing away at the religious basis for their authority, and to train loyal bureaucrats for their civil service. Such foundations are generally laid out around a high and relatively exiguous courtyard,paved in marble with a pool for ablution in the centre. A projecting wooden roof with eaves supported on carved and painted consolves offers shade from the blazing sun, and there are various indispensable services, cells for students, sometimes arranged over a number of floors, and a prayer hall.