refactor and add several of the missing cases in inferType; add inferType' which compeletes the type resolution