Generics added

And a few typos corrected, ready for pull request