My wife and I are well aware of the stress that buying a home can cause. We’ve bought three homes and taken out three mortgages in the last few years.

When you’re planning to buy a home, getting a mortgage needs special attention. The mortgage you end up with might be the biggest debt transaction of your life. Getting the best interest rate possible will save you some serious money over the life of your mortgage. For example, if you take a $300,000 mortgage at 4.0 percent for 30 years, you’ll make $515,610 in total payments. But if the rate goes up to 4.25 percent on the same mortgage, you’re looking at a total payment of $531,295.20. That’s an extra $15,685.20!

One of the biggest factors that will affect the interest rate on your mortgage is your credit score.

I recommend getting your score up years before you want to purchase a home.

Even if you’re just a couple of months away, there are many things you can do to boost your credit score.

Make Sure Your Credit Report Is Accurate

The first thing you should do is visit to get your credit reports for free. (You can do this once every 12 months for each of the three major credit bureaus.) The information on your credit report is exactly what credit-scoring companies use to calculate your score.

Once you have your credit reports in front of you, make sure everything on them is accurate. Keep an eye out for any negative information on your reports to verify its accuracy.

If there is a negative item on your report that is wrong, dispute it immediately. You can try disputing the item with the creditor directly, but you’ll also want to file a dispute with the credit bureau from which the credit report was pulled. Make your case with proof, and be honest during the dispute for the best chances of success.

Further Reading: If you have inaccurate info or a poor credit score, you may want to learn about credit repair.

Focus on the Five Credit Score Categories

Your credit score is calculated based on five categories, each of which makes up a percentage of your score. If you have limited time or resources, focus on the biggest categories. That said, all categories earn you credit-score points, which will get you closer to your best mortgage interest rate.

1. Payment History (35 percent)

Payment history is the largest portion of your credit score. Other than disputing erroneously reported late payments on your credit report, the only thing you can do is make all your payments on time going forward.

2. Amounts Owed (30 percent)

“Amounts owed” is the second largest portion of your credit score. You can do a bit more here to improve your score. To get the best score possible, you’ll want to owe as little as possible.

To improve your score in this category, keep your credit-utilization ratio low on your credit cards. You definitely don’t want to have any maxed-out credit cards, since that could severely affect your score. If possible, try to keep your balances at zero by paying off your balance just before your statement date. Why? The amount owed on your credit report is usually the same as your statement shows.

This is one area my wife and I focus on before applying for a mortgage. We aim to keep our credit card statement balances as close to $0 as possible each cycle before applying for a mortgage.

3. Length of Credit History (15 percent)

Length of credit history is a smaller category but an easy one to maintain. Avoid applying for new credit before taking out a mortgage. Why? Applying for new credit will reduce the average age of all your credit accounts.

Want to lengthen your credit history? If you have a friend or a family member with an old credit card, it may help to be added as an authorized user on that account. Sometimes that history transfers to you, increasing the age of your oldest account.

4. Credit Mix in Use (10 percent)

Your credit mix is a small portion of your score, but every point counts. Aim to have a mix of credit cards and installment loans on your credit report.

5. New Credit (10 percent)

New credit is super simple to manage before getting a mortgage. Try your best to avoid applying for any new credit for at least the few months before you apply for a mortgage. If possible, try to stretch that to a year.

This category is tough for my wife and me, since we love earning credit card sign-up bonuses to use for travel. Even so, we stop applying for new credit as soon as we know we’re going to get a new mortgage.

Every 0.125 percent makes a difference when it comes to mortgage interest rates. Working on your credit score before applying for a mortgage may save you a few eighths of a percent—and thousands of dollars over the life of your loan.