Extracted the Counting interface.

Closes #401.