Fix up crash around weak ref usage

Change-Id: I45198f1b3ba4ad5a657f323aa322f0ac3808d6d4