Added support for generators.