Move some variables closer to usage