Role of defects in the metal-insulator transition in VO2 and V2O3