Get rid of static variables for SETOF result, don't crash when called from non-FROM context, eliminate dead code, etc.