The role of transition metal impurities and oxygen vacancies in the formation of ferromagnetism in Co-doped TiO2