Fix PrintTable and table.ToString infinite looping

when trying to print a table that contains itself.

Also added table.ToDebugString, which outputs the top level of key,
values only.
Improved hook and SGUI error reports

They now show which event has errored, and display all local values from
the function that caused the error.