Remove references to global variables and their creation

Hello,

I noticed there were a couple of places where global variables were created.  There were no obvious reason why, so I assumed they were created by accident.

Also found code that referred to non-existent variables.  Figured those were accidents as well, so I fixed them best I could.

-Xavi