The Treasury Department on Friday announced it would rework the terms of its bailout of mortgage giants Fannie Mae and Freddie Mac to make sure taxpayers benefit from any profits. The government also affirmed its backing of the two firms, a move intended to assure the lending industry, which counts on Fannie and Freddie to finance the nation’s mortgage market. The renegotiated terms of the four-year-old federal conservatorship require the firms to downsize the number of mortgages they hold on their books by 15 percent annually, up from 10 percent. In addition, the revamped agreement alters the way in which Fannie and Freddie repay taxpayers. Under the new arrangement, any profits that Fannie or Freddie make would go entirely to the government each quarter; the government would receive no payment if the firms do not turn a profit.