The group-III nitride semiconductors have many important commercial applications in optoelectronic devices. They are also candidates for fabricating ultraviolet light-emitting devices (LEDs), which could replace gas lasers and mercury lamps for applications such as air and water purification, disinfection and high-resolution photolithography. To achieve high-efficiency UV lasers and diodes, bulk AlN substrates and high Al-content AlGaN alloys will likely be required, along with a better understanding of the role of defects and impurities in AlN. Several theoretical studies on AlN have been published; however, the majority of these used traditional density functional theory (DFT) functionals, such as the local density approximation (LDA) or the generalized gradient approximation (GGA). These methods severely underestimate the band gaps of semiconductors, which leads to large uncertainties in the position of defect transition levels and formation energies. In this work, we employ a state-of-the-art hybrid functional, developed by Heyd, Scuseria, and Ernzerhof (HSE), which includes a portion of Hartree-Fock exchange. This method gives accurate band gaps and lattice parameters, and allows for much more accurate calculations of defect transition levels, albeit at a significantly greater computational cost. One of the outstanding problems in the study of AlN and high Al-content AlGaN is the formation of so-called DX centers, also encountered in GaAs and AlGaAs, which consist of donor impurities that self-compensate by turning to acceptors as the Fermi level approaches the conduction band. We use the HSE functional to analyze the electrical properties of oxygen, silicon and germanium donors in AlN and GaN, and evaluate the possibility of DX center formation. For the oxygen impurity, we find a stable DX center in AlN and a metastable center in GaN, in agreement with previous theoretical and experimental results. However, the structure of the defect differs from previous GGA calculations. By using linear interpolation, we predict at what Al concentration oxygen transitions from shallow donor to DX behavior in AlxGa1-xN alloys. In the case of the Si and Ge donors, a stable DX center is found for both impurities in AlN. As before, transition concentrations are determined, and the structure of the defect is studied. This work was supported by NSF, by the UCSB Solid State Lighting and Energy Center and by the Institute for Energy Efficiency.