Fiscal cliff deal forged in flurry of final talks