Make substitute work for type variables as well.