We recently adopted a male cat, age 7, who started having litter box issues almost immediately. When I brought him to the Vet he suspected (as I had) that "allergies" were not the reason the cat was turned in to the shelter. I left him at the Vet overnight and they got what they needed. They found a severe UTI to include two types of bacteria, blood, and crystals. The Vet said it was long term. He's currently being treated at home and seems to be doing much better :)
Peeing outside the litter box = Cat 101. This is almost certainly not a bad cat, but a sick cat. Even if behavioral help can be had.