(*) Refactored TypeFactory to make it re-use the same logic in more places and improve logging to make it easier to find why a type cannot be constructed