Fix list of variable declaration

Due to commas replaced with semicolons, the assignments started
with local variables and ended with global variables (undeclared);
Rename variables declared to match variables used