Fix issue with weak references
Merge pull request #1261 from reciprocity/feature/fix-weakref-error

Fix issue with weak references