Defects and impurities in amorphous semiconductors and in liquid electrolytes