Fixing some bugs with the generator implementation