Adding generic support to the counter

This makes the counter more useful and specialized
Merge pull request #1 from pspeter3/generics

Adding generic support to the counter