Use a weak reference for the delegate.

Fix #78.
Merge pull request #200 from paulyoung/delegate-weak-reference

Use a weak reference for the delegate.