move some globals into main