In his last years, my dad, of blessed memory, became a prolific storyteller, and like a lot of people in what some call their “anecdotage,” he often repeated his stories, in ways that suggested to me that they had been carefully chosen. They became, I sensed, his foundational stories — the episodes that meant the most to him and best described who he was.

The curious thing was that my dad was not always the moral hero of these stories. Don’t get me wrong — these weren’t deathbed confessionals. But there was a story about him cheating on a test. And a few about how faced with a choice between principle and prudence, he went with prudence.

I always wondered why he told these stories, especially when he had the option of being his own editor. One possibility was simple honesty. Or perhaps he meant to teach us that we are shaped by the choices we make — good and bad.

I thought about the way we cull our memories when I was asked to give a d’var Torah — a sermon — on the Torah portion Matot-Masei (Numbers 30:2-36:13), read this year on July 18. It includes an absolutely hair-raising account of divine revenge and, let’s face it, genocide.

In the portion, Israel is at war with the Midianites, with whom just a few chapters back the Israelites had been cavorting and worshiping the strange god Peor. A strike force assembled by Moses slays every male Midianite and their five kings.

Moses hears about the victory, but he is angry. “You have spared every female! Yet they are the very ones who, at the bidding of Balaam, induced the Israelites to trespass against the Lord in the matter of Peor, so that the Lord’s community was struck by the plague. Now, therefore, slay every male among the children, and slay also every woman who has known a man carnally; but spare every young woman who has not had carnal relations with a man.”

To which I can only say, yikes. This is at the very least what has become known as “total war”; we might call it a war crime.

I think most of us are uncomfortable when we arrive at these sorts of stories — unless, perhaps, you’re Rabbi Meir Kahane, for whom this was a favorite passage. “No trait is more justified than revenge in the right time and place!” wrote Kahane.

But how do sane people deal with these morally challenging stories?

Traditional commentary justified Moses’ orders with variations on the claim that the Midianites were so bent on subverting Israel’s morals and religion that Israel had not only to wage war on this generation, but to prevent another from arising.

Thomas Paine read stories like these and concluded that the Bible is “a book of lies, wickedness, and blasphemy; for what can be greater blasphemy than to ascribe the wickedness of man to the orders of the Almighty?”

Contemporary Jews have tried to steer a middle course between justification and denunciation. Rabbi Brent Rosen, in his blog about Torah and social justice, describes the range of interpretations, from the “abject apologetic approach” (essentially, desperate times called for desperate measures), to scholarly denial, which suggests the massacre was not actually carried out, “thus avoiding the essential moral problem.”

Still others “spiritualize” the horror, turning it into a metaphor for inner growth — that by exposing our tribal instincts and thirst for revenge, the passage becomes a teachable moment.

Considering the dangers of justifying awful deeds as the will of God — a tendency we saw on display in last week’s deadly attacks on a Palestinian family and at Jerusalem’s gay pride march — I can think of far better ways to achieve spiritual growth than reading stories about our ancestors’ cruelest acts. In a powerful column this week, Chemi Shalev of Ha’aretz provides a nauseating catalogue of violence carried out by extremists in the name of Torah and the leaders and teachers who encouraged or condoned their fanaticism.

My teacher Rabbi Irwin Kula once said that we learn difficult texts because it is a reminder of who we are: a holy nation, but also the product of vicious tribal conflict and outmoded concepts of revenge and holy war. And perhaps that was my father’s lesson as well — we are the sum total of all the choices we make, and to pretend otherwise is dishonest.

The “problematic” stories, meanwhile, reassure me how far we’ve come from the morality of the Humash — how our views on slavery, warfare, homosexuality, the treatment of women, and diversity have evolved over the millennia. They remind me how the tradition, from talmudic days onward, consistently mitigates the cruelest aspects of the Five Books of Moses. They remind me that ours is a living tradition and that we have the capacity to remember not only who we were but celebrate what we’ve become.

But that also assumes that we read the Bible as a family story, not an instruction manual. Woe to us if we forget the difference.