We have investigated the effect of gallium deposition and desorption cycles and ultrathin (15 Å) AlN layers on the oxygen impurity concentrations in homoepitaxial N-polar GaN layers. Secondary ion mass spectroscopy (SIMS) indicates that three Ga deposition and desorption cycles reduce the total oxygen by 70%–80%, while ten cycles reduces the total oxygen by more than 90%. We present a model of surface segregation and incorporation which accurately captures the distribution of oxygen in these layers. By fitting the model to the SIMS data, we are able to determine the fraction of an oxygen layer adsorbed on a GaN surface which segregates upon initiation of epitaxial GaN growth. Under the conditions investigated, we find this fraction to be 80%.