Changes to main routine