Return an object when constructing Generator

Fixes a bug introduced by removing 'new'.