Timing key to Shalit release deal
It is clear from the deal struck to release the captured Israeli soldier Gilad Shalit and more than 1,000 Palestinian prisoners being held in Israeli jails that most of these people could have been freed a lot earlier.
There is very little in this agreement that has not been on the table for years. The key sticking point was always the release of high-profile prisoners like the influential Palestinian leader Marwan Barghouti and the head of the Popular Front for the Liberation of Palestine, Ahmad Saadat.
Hamas has always insisted it must win the release of key players. Israel would not budge and so the deal went nowhere.
So what changed?
The Israelis say Hamas stepped up to the negotiating table almost as the President of the Palestinian Authority (PA) Mahmoud Abbas stepped down from the podium in New York last month having delivered his speech calling for UN membership.
Mr Abbas's bid has proved hugely popular with the Palestinian people. For once they were seen to have wrong-footed Israel on the diplomatic stage, an arena where, in the past, they have been woefully inadequate.
Mr Abbas's standing soared and people in the occupied territories felt, perhaps for the first time, real hope that his non-violent resistance to the occupation could bring results.
As his and the PA's star ascended, Hamas's dropped. Since it won legislative elections in the Palestinian territories back in 2006, the militant organisation has seen its popularity slowly decline.
Its regular trade of rockets and missiles with Israel has done little to raise local morale. The Israeli blockade made life unbearable for many Gazans.
Israel was forced to ease those restrictions last year after the storming of the ship the Mavi Marmara which was taking part in a Gaza-bound flotilla.
Nine pro-Palestine activists were killed and the international community rose up as one in condemnation of the blockade.
As Israeli officials eased the blockade, they changed tactics and began focusing more on the smuggling of money into the Gaza Strip from Egypt.
A cabinet minister told me privately that Israeli army air strikes were used to kill apparently low-level targets, but they were low-level targets transporting lots of money.
Hamas was running out of cash and attempts to raise taxes on things like cigarettes and fuel alienated them further from the local population. So they bit the bullet and did a deal they had been resisting for years.
The Egyptians became key. Syria's slow meltdown left Hamas' leadership facing the prospect of needing a new home. Egypt would be their least worst option and it was applying pressure for a deal.
Last night Egyptian officials were shuttling between two hotels in Cairo passing on negotiating positions to a delegation from each side.
Hamas won some last-minute concessions from Israel, which is itself trying to adapt to the new realities of the region post-Arab Spring.
One new aspect of the deal was the inclusion of 27 women prisoners - some of whom are notorious figures whose release the Israeli public may find hard to swallow.
It also got Israel to agree for the first time on Israeli Arab prisoners being included in the negotiations.
Soon after the BBC broke the story of the deal and approached the Israelis for comment, Prime Minister Netanyahu hastily arranged an emergency cabinet meeting to get a sign-off on the plan and declare: "I am bringing Gilad Shalit home."
Palestinian politics is a zero-sum game. For now Hamas will bask in the glow of having got more than 1,000 Palestinian prisoners in exchange for one man.
Mr Abbas, while publicly welcoming the exchange, woke up this morning a politically weakened figure.
But when the jail doors open - probably next Tuesday - and people begin going home to their families, it will be clearer that key political Palestinian militants, seen as heroes by many people in the occupied territories, will still be behind bars.
Hamas has just played their only trump card. It has unquestionably won the round. But will it be enough to win them the game?