When you do not have your pup in a gated area, you need to have a belly band on him. This will save your carpet AND your sanity, you poor thing! Check this out!
http://www.pekeatzurescue.com/bellybands.html
(I have never used this particular product, but it gives pictures and a perfect description.)
As to your stinky carpet, try Simple Solution to clean all traces of the urine and scent out of there. If your pup can't smell it, he may not pee there.
And next time your pup pees on the carpet, roll up a newspaper and hit yourself over the head while chanting "he should have had a belly band on, and I should have watched him closer"!
Good luck!! Believe me, we have all had our potty training frustrations. I am going through one now. I don't promote smoking, but if it keeps you calm and keeps you from abusing your pup, SMOKE LIKE A CHIMNEY, BABY!!