Moved some vars into the main function (since they are not used anywere else in the code)