For the orange part: it can becom >4 if 2 notices are sent within 2 seconds. If the channel gets busy where 3 different repeats are received within 5 seconds or so, only 2 notices are sent...
As for using $hash: I didn't use it because then you're storing hash values in a hash table. Seems perfect at first, but if you think about it