Moved some variables from global scope to functional scope