fix global leak. Fixes #690