Fixed the case when gfunc_init was called with shp[2]==0