Fixed name lookup in template instantiations