Fix a segfault issue, and var shadow issue