Make toClass() recursive.