Infestation of carbonate grains by endolithic organisms undermines and weakens grain surfaces which collapse due to impact. Pits formed by collapse are filled with debris and carbonate cement. This process is observed in ooids from the Bahamas; the Yucatan Peninsula; Texas; and the Arabian Gulf. Pit-filling cements resemble the carbonate making up the primary ooid cortex. Pit formation and infilling lead to alteration of the ooid cortex, forming irregularly shaped patches of poorly or randomly oriented crystals which cut across primary laminae. The crystal forms differ from intragranular cements in form and size. The entrapment of foreign material and their subsequent cementation in place provide a mechanism for incorporation of foreign material observed by previous workers. Similarity between pit-filling cements and primary ooid cortical material suggests that their mode of precipitation is similar. The most common pit-filling cements, aragonite nannograins and rods or batons, are associated with algal and/or mucillagenous filaments and films, and are formed by their calcification. Because ooids forming today have cortices composed of aragonite rods and nannograins, these observations agree with those of others that ooid cortices are formed primarily by the biochemically or biologically mediated process(es) associated with calcification of filaments and films formed by algae.--Modified journal abstract.