Fix leaf testing and tree.op index