Fixed undefined variable issues.