We show that by adding an extra purge gas pulse perpendicular to the substrate surface, the carbon impurities in the film decreased drastically to approximately 1 at.% giving a Al/N ratio of 1.07. The surface chemistry and the role of the extra pulse between TMA and NH3 was investigated with quantum chemical and kinetic modelling. It was found from the modelling that the most loosely bound surface methyl groups can desorb quickly with negligible reaction barrier. The added pulse between TMA and NH3 is therefore believed to clean the region just above the surface from desorbed methyl groups, suppressing any re-adsorption of the desorbed methyl groups. It was found both experimentally and from the calculations that the desorption of the surface methyl groups increases with increasing temperature. The growth of the AlN film was somewhat dependent of the extra pulse time were longer pulses gave smaller growth rate which were attributed to less C impurities in the film. The type of gas used as the pulse between TMA and NH3 was found to have a stronger impact on the crystallinity were the crystallinity of the films increased when going from Ar, N2 to H2, we ascribe this to the thermal conductivity of the gases.