Reference counting for generator cleanup

to avoid a slow memory leak in the Dispatcher cache.