A density-functional based tight binding method was used to study elementary steps in the growth of ultrananocrystalline (UNCD) diamond. It was shown previously that C2 dimers are the dominant growth species in hydrogen-poor argon plasmas. Recent experimental evidence shows that nitrogen addition to the plasma profoundly changes the morphology of the UNCD film. CN species are believed to play a major role. Reactions of C2 and CN molecules with reconstructed diamond (100) surfaces were studied. A single CN prefers an end-on attachment to a surface atom on the unhydrided (100) surface with its C end down. It is shown how further C2 addition to the surface leads to CN-mediated diamond growth and how the CN species remain on top of the growing diamond layer.