Better checking of type compatibility