Fix global variable leaks
Fix global variable leaks


Former-commit-id: 932f85f83e25940b412ac7d0ba946959530c126b [formerly 5f160189aafa65cda2b909eda39b051388628c98]
Former-commit-id: 3dfeecdd18ea955a7e2d9a5aa134b78daae9c917
andrewplummer/Sugar,romancow/Sugar,romancow/Sugar,andrewplummer/Sugar