Fix infinite loops with negative counts

Negative counts are now treated as zero
Fixes #131