Electronic structure of defects in III-VI and II-VI semiconductors and novel Yb-based intermetallics