You could always insert a timer to delay the nick change. If the timer were longer than the lag it would solve that problem anyway.
[Added]
I have also been told, rather forcibly, by those who write services that it is
NOT A GOOD THING tm to use the RAW command ...
