logElementTreeJSON, etc

I can break this up into separate pull requests if desired.

Tested with Xcode 4.6.2