Which fool compared integers with 'is'?! Oh wait, it was me. Fixed.

Furthermore: prevent Python integer caching by choosing a high value for COUNTER, thus catching these type of errors earlier.