Changed scope of variables that store graph information to ensure proper refreshing.