Guard against counter overflows.

Closes #33