You could just use dynamic variables as well, for example:
on *:kick:#: { inc % $+ $knick }
Creates/increases the variable for that nickname. you can do
on *:NICK:{ if (% $+ $nick != $null) { set % $+ $newnick % $+ $nick unset % $+ $nick } }
to account for nick changes that way