Fixed code and tests because Tree.SafeIndexOp was removed from language model