I think the key to preventing cats from scratching where they shouldn't is to provide them with good alternatives. Sounds like Fredrik enjoys horizontal surfaces with carpet material, so a large stable scratching post with a horizontal carpet covered surface is what you're looking for. Something like these -
[product="18612"]Sleeky Lounge Xl Big Cat Scratcher Lounge [/product]
You can even make your own, just make sure it provides a large stable horizontal surface, preferably covered with a carpet-like material. This should be placed in a central location, ideally in the same room where the cat scratches the carpet (as scratching can have a territorial significant too). Once that's all set up and Fredrik knows all about it (i.e. found it and hopefully started using it) you can try and deter him from using the carpet using deterrent sprays like the one you mentioned (there are others). If you use only the deterrent and the cat has no suitable alternative, it may not work.
More about scratching behavior and how to redirect it -
I'm thinking of a horizontal one for him, he has a massive cat tree/ condo that he loves to bits and a little scratching post he uses every now and then as he is beginning to get to long for it now.
We have just recently moved into a new apartment block and I think there are one or two other units with cats so I did have a feeling it may have been territorial.
Thank you very much for your help. And thank you for such a wonderful site! I think I would have gone crazy without it!