fix some leaked globals; fixes #1823