The formation and effect of O-vacancies in doped TiO2