Fixing bugs in generator