Perhaps the addition of something like $trace(), which could be used to trace backwards through functions/events...
eg. $trace(N) with properties .type (event, function, raw, etc.), .function, .script, .scriptline, .scriptdir, .event (ctcp, text, input, etc.).
I'm not sure if a .scriptdir property would be worthwhile if .script is there, but whatever.