To understand this, you have to understand what happens to bread while you bake it. I get all of my information from The Bread Baker's Apprentice by Peter Reinhart.
First you need to gelatinze your starches (which make up 80% of the flour in your bread). During gelatinization starch absorbs and traps as much liquid as it can hold then bursts, flooding the liquid with starch molecules and thickening the mixture. This happens between 180 degrees F and 212 degrees F. So the center of your bread has to reach 180 degrees F for this change to take place. Otherwise the texture will always be a bit doughy. This is probably the main cause of your problem.
Second you need to caramelize sugar on the crust. This happens at 325 degrees F. This will happen early, as your crust reaches nearly the temperature of your oven.
Third the proteins in your bread need to be denatures, coagulated, and roasted. Proteins are tightly coiled molecules. They denature (unwind and straighten) between 140 and 145 degrees F, then as temperatures rise they wrap themselves with each other to create tightly bound chains of proteins (coagulate). After that the proteins roast to create a nice flavor. If you bread didn't even get to 140 degrees F it won't be quite right.
For a hard crusty bread you should bake to 200 degrees F internally. For a soft, enriched bread it must reach at least 180 degrees F.
After baking cooling is also important to avoid a doughy textures. As long as the bread is above 160 degrees F it is still gelatinizing. If you cut into it you'll mess up the process. You need to let it cool down. Not only are your starches settling but your bread is sweating (moisture is evaporating) and the taste is intensifying.
So the main key to avoiding rawness is gelatinzation, and the two steps are baking to 180 degrees F and letting it cool down past 160 degrees F before cutting (but ideally cooling to room temperature for optimum flavor).
Your second bake probably didn't get to 180 degrees F in the center, as you would've quite burned your crust by then.