Dopants and defects in proton-conducting perovskites