Fixes in type instantiation code for both function calls and patterns