Ensure compilation does not leak global variables. Fixes gh-496