Fix up crash around weak ref usage

Change-Id: If074d75e410a2db1391654d48069e5381ffa9823