Fixed tag replacement in FLAGs with the INSERT action

Hi Jeremy. There were some errors with tag replacement in FLAGs that had the INSERT action.

Here is the test script I used to discover the problem initially: http://pastebin.com/204mknWw

And here is the error that I was getting from that: http://pastebin.com/cwpz8Y8E

But I have fixed the issue.