How would capital gains be calculated on the sale of two houses in AZ (community property state) within two years of the death of a spouse?

Would there be any exclusion of capital gains for either home, and would there be a step-up in cost basis for the second house like there would be for the first home? Furthermore, would selling the houses in the same year as the spouse’s death, when the widow would still have a tax-filing status of “married filing joint,” be advantageous?

 

Also, if the proceeds from the sale of both houses were used to purchase a new home in CO, could a 121 home sale exclusion (for the primary home) and/or a 1031 exchange (for the second house) be used to defer capital gains?

For example, the primary home was bought in 2010 for $220,000 and $140,000 worth of improvements were made for a total cost of $360,000. The house’s appraised full fair-market value at the time of the spouse’s death was $502,000.

 

The second house was bought in 2010 for $226,000, and $76,000 worth of improvements were made, for a total cost of $302,000. The house’s appraised full fair-market value at the time of the spouse’s death was $468,000. The widow’s parents lived in the second home rent-free but paid the property taxes, the property insurance, and the HOA dues. No deductions were ever taken for the house and the widow and her spouse I never lived in the second house.