Fix var declarations
Merge pull request #1 from raymondfeng/master

This PR fixes global var leaks