Refactor tracing in preparation for another uber cool tracing handler.
Misc test case fixes and memory issues.

Already part of Xdebug proper too, but needed it in here to be able to proceed.
ZTS issues and test fixes
Merge branch 'triceratops-refactor'