RIO DE JANEIRO (AFP) - Michael Phelps' past and present converged at the Rio Olympics in a last explosion of gold for a swimming icon who showed he is more than a "medal machine".
After amassing 22 medals, 18 of them gold, in four prior campaigns, Phelps delivered an epic ending to his Olympic saga in Rio de Janeiro, powering to five gold medals and one silver in seven days at the Olympic Aquatics Stadium.
He leaves Rio with a mind-boggling 28 medals to his name, 23 of them gold.
In a departure from Games past, Phelps' fifth Olympics offered a glimpse not only of a sporting great relentless in pursuit of success but also of a man buoyed by warm family relationships heading purposefully into his post-swimming life.
That was not a picture presented before by Phelps, not as a young striver in his first Olympics at 15 in Sydney in 2000, not in Athens in 2004 where he arrived already working his way into the ranks of heavyweights alongside Ian Thorpe and Pieter van den Hoogenband.
It certainly was not the Phelps of 2008 in Beijing, when the unprecedented achievement of eight gold medals at a single games required an isolating determination and focus.
London 2012 was supposed to provide the fond farewell. And it was not until after the fact that Phelps lifted the curtain to reveal the anger and unhappiness of those Games, when he wanted nothing more than to be done with swimming.
Despite four gold medals and two silvers, Phelps was "haunted" by knowing he failed to prepare as he could have and particularly stung by the loss of the 200m butterfly title he surrendered to Chad le Clos.
Rio, according Phelps' coach of 20 years Bob Bowman, was the swimmer's chance to fashion the ending he deserved.
"He mentions it all the time that he wants to go out on his own terms - on good terms, not 'Let's get out of here,'" Bowman said.
But the comeback mounted in 2014 ground to a halt when Phelps' personal demons caught up with him in a Maryland tunnel, where he was clocked driving 135kmh in a 72kmh zone while under the influence of alcohol on September 30 of that year.
The incident launched Phelps on a "brutal" personal journey that included a stay at a facility specialising in personal trauma and addiction treatment.
There Phelps, who after his parents' divorce was brought up by his mother, Debbie, reconnected with his estranged father. That renewed relationship has taken on even greater resonance since Phelps himself became a father when fiancee Nicole Johnson gave birth to their son, Boomer, in May.
Johnson and Boomer were front and centre in Rio, Phelps sealing the celebration of his longed for 200m fly victory with a tender kiss for the baby boy as the Olympic crowd roared.
It was the kind of expansive public demonstration the old Phelps rarely allowed himself, just as the old Phelps would not have let himself get too emotional on the 200m medley medal stand, knowing he had a 100m butterfly semi coming up.
"That was nice to see, actually," said Bowman, adding that in the past he would have counselled Phelps not to bask in the moment but to "build the fire up in you while you're hearing the national anthem".
"He's usually like a machine on those," Bowman said, invoking a word often used in connection with Phelps.
Bowman himself has called Phelps a "motivation machine" spurred to action by the slightest snub, and the sheer number of his triumphs - reeled off with metronomic regularity - have earned him the reputation of a "medal machine".
Bowman, however, said each one of those golds was the product of sweat and stress.
"Every one of those was hard," Bowman said. "Maybe the very first one was the easiest one. After that they've all been super-hard."
Bowman, who first detected the determination he cites as Phelps' greatest asset when he began coaching the 11-year-old swimmer, has lived through some stormy times with Phelps.
He watched as Phelps fought through youthful scandals including his first drink-driving charge at 19 and a tabloid ruckus over a picture of Phelps with a marijuana pipe in 2009.
Their relationship hit rock bottom as London approached, but Bowman said Phelps in Rio is really changed.
The 31-year-old soaked up aspects of the Olympic experience he previously ignored - serving as a captain on the US team for the first time, carrying the US flag at the opening ceremony he had never before attended. Then he dived in and did what Michael Phelps does, helping the US to gold in the 4x100m and 4x200m freestyle relays, avenging his 2012 200m fly loss to le Clos and notching his fourth straight 200m individual medley title.
Even his lone silver - to Singapore sensation Joseph Schooling in the 100m fly - carried a whiff of the extraordinary: it was a rare three-way tie with le Clos and Phelps' longtime Hungarian rival Laszlo Cseh.
"I think he wants to wrap it up knowing that he gave everything and prepared well did it the right way," Bowman said. "And he loves it."
His success in the pool - far from assured when the Games began, begs the question, "how do you not come back?"
"I just don't see it happening," Bowman said. "I think he's in such a good place personally he doesn't need it. "I think he's got a lot to do, I think he has a plan for what he's going to do with his life, and he's just in a good place."