Fix global variable leaks
Merge pull request #328 from terasaka2k/master

Fix global variable leaks.