You should first check to make sure its not a medical issue - early signs of a urinary tract infections are sometimes mistaken for spraying/marking. Have him examined by your vet to rule out that possibility. And of course it could be that he is trying to mark territory aswell. Clean up the areas to remove the scent and markings, shampooing the carpet and cleaning the walls with a urine nuetalizer like "natures own/best", ask the associates at your local pet store for the exact name. And to nuetralize the behavior the use of a water gun when you catch him in the act of spraying comes in very handy to stop unwanted habits. I hope I helped.