Add generics and new module system support
Merge pull request #664 from vagarenko/master

Added generic typing and converted to TS 0.9 module