Function names on queries, some debugging output (latter not by me)