Added var to some accidentally global variables