Fixed global var ref issue.