Progress on type inference

But not quite there yet.