Use generics
Merge pull request #30 from timowest/master

Improve API by using generics