Unfortunately it has to be done this way. It is basically translating a preprocessor style tagging system for a lot of old code that can't be altered. I'll give your suggestions a try, cheers!
I see your point about 'rm' though. Currently I'm only allowing know tags through, hence the idea of stripping the 'if' and then using the code's own 'if'. Meaning only the logic section would be used. If that makes sense.