We describe the use of first-principle calculations to address problems related to defects, doping, and band- structure engineering in III-V nitrides. For n-type doping it is found that nitrogen vacancies are too high in energy to be formed during growth, but silicon and oxygen readily incorporate as donors. The properties of oxygen, including DX-center formation, support it as the main cause of unintentional n-type conductivity. For p-type doping we find that the solubility of Mg is the main factor limiting the hole concentration in GaN. We discuss the beneficial effects of hydrogen during acceptor doping. Compensation of acceptors by nitrogen vacancies may occur, becoming increasingly severe as x increases in AlxGa1-xN alloys. Acceptors other than Mg are also investigated. Finally, we discuss our first-principles investigations of the atomic and electronic structure of heterojunction interfaces between the III-nitrides, and provide values for band lineups.