Weak ref change for #668 and #729
Merge pull request #779 from kjeremy/v3.1

Weak ref change for #668 and #729