By Nick Assinder
Political correspondent, BBC News website
It is not hard to imagine David Cameron's fury when he heard of the comments made about black soldiers by his frontbencher Patrick Mercer.
The Tory leader has spent the past year or more devoting all his energies to casting off all the old negatives which used to attach themselves to his party.
Mr Mercer has retracted his remarks
Then, with a highly controversial set of remarks, Mr Mercer risked blowing it all apart and handing the party's opponents a chance to claim the leopard had not changed its spots.
Labour's Shahid Malik, for example, said the remarks showed the Tories remained the "nasty party".
"It doesn't matter what they tell you, they still are the nasty, racist,
sexist, homophobic party they have been for many, many, many years," he said.
Mr Cameron would undoubtedly reject that image of his party, but he knows it has occasionally been the public perception.
That is precisely why he has been expending so much of his energy on changing the party in a fundamental way to make it more inclusive, diverse and tolerant.
So, once again, he believed he could not afford to give any ground on this matter and acted swiftly to sack Mr Mercer in an attempt to send out the strongest possible message that he means what he says about changing the party.
People who know Mr Mercer claim he is not a racist and have been surprised by the events.
Mr Cameron moved swiftly to sack Mercer
He clearly believed, as friends have said, that he was simply describing the world - specifically the military world of which he has personal experience - the way it is.
But, whatever the arguments for and against his comments, they displayed a large degree of political misjudgement.
The very fact he appears to have been taken by surprise at the level of the furore caused by them is evidence of that.
One possible positive from all this is that the issue of racism in the military is again back on the agenda with top brass insisting it will not be tolerated.
But, for Mr Mercer, his remarks have brought to a premature end what many believed had the makings of a successful frontbench, even ministerial, career.
And for Mr Cameron it has undoubtedly set back his "modernising" campaign, leaving him having to make up lost ground.