added code to reset some variables before gameloop is reinitialized by user