Change some TypeError to ValueError