The best way to come out ahead, spending-wise, is to buy something you really like and will hang onto for a long time. What you don't pay for initially can come back to haunt you if you:
(1) have to send it back to the manufacturer or seller on your own dime, or pay a gunsmith to fix it
(2) are not satisfied with the gun and (a) trade it or sell it at a huge loss, (b) keep it but never shoot it because you don't want to lose money, or (c) spend a bunch more money on upgrades in an effort to like it more.
Identifying what you really want isn't always easy, but I think you can narrow it down quite a bit through reading, handling a lot of guns at the store, and renting your favorites if possible.
For $500 inclusive, you could have a new Springfield XD from Budsgunshop.com. That's what I would do, because:
* I already know that I love XDs and own two.
* This is an excellent price for an excellent gun that, IMO, requires no modifications whatsoever. Modifications cost more money (new grips, better sights, trigger work, etc.).
* If necessary, I can send it to Springfield for repair on their dime. Last time I sent a gun back (to Ruger), it cost me $55 to ship.
* There is a high demand for them, and they have a reputation for quality, so I wouldn't take quite as much of a beating if I decided to sell it.
Just keep in mind that the gun industry gets paid no matter what, and the price tag is often only your first payment installment for a particular gun. Consider what you pay and what you get, in totality.