Localize global variables, worked on generate function, changed generator function name.