Made some variables static to avoid repeated initialization