Mechanism of Fermi-level stabilization in semiconductors.