Ammonia has been used to grow GaN layers by molecular beam epitaxy on c-plane sapphire substrates. The ratio of nitrogen to Ga active species, i.e., the actual V/III ratio, has been varied from 1 to 4. It is found that increasing the V/III ratio improves the material properties both in terms of optoelectronic and structural quality. This is demonstrated by photoluminescence (PL) experiments, Hall measurements, secondary ion mass spectroscopy (SIMS), and atomic force microscopy. The origin of the residual n-type doping of undoped GaN layers is also discussed on the basis of SLR IS and PL results.