Added pre-cached tree traversal and JSON generation - fixes #27