Made some variables in main function into fields