After a number of previous failed attempts, King Sebastian established the foundations of a standing army, with the creation of the "Ordenanças" in 1570. The "Ordenanças" was a militia-type territorial organization aimed to provide a military framework for the Portuguese population and to create a nationwide standardized system of military training and mobilization. It was organized into 250-man companies, each headed by a captain, assisted by an "alferes" (ensign) and a sergeant. The several "Ordenanças" companies of a city, town or municipality were grouped into captaincies, each headed by a captain-major, assisted by a sergeant-major. The "Ordenanças" system would cover virtually all available manpower of Portugal and become part of the basis of the Portuguese military organization until the 19th century. Its efficiency would soon be evidenced by its important contribution to the raising of the expeditionary army that would fight the 1578 Moroccan campaign.