Deductions & credits

the capital gains is based on teh following:

 

1) the sales price of the house LESS

2) improvements you made to the house while you owned it LESS

3) the costs associated with selling the house - the big one is normally the commission LESSS

4) the original purchase price price of the house EQUALS

5) the gain on the house

 

from #5, you can further remove $500,000 as the joint exclusion as long as you BOTH lived in the home at least 2 of the last 5 years. 

 

from your post, you didn't mention #2 and #3 as opportunities to reduce the gain.