Mechanisms for energetic-vacancy stabilization: TiO and TiC