Bug with aliases in multiple loops

There was a bug where if you use a foreach alias and then try to do it
again, the alias would carry over. This patched the bug but some of the
"this.[VAR]" additions might be unnecessary because i also forgot to
replace a semicolon with a common during variable declaration. Will
update on this later.