This use of weak ref looks fine (and I can't think of an alternative way)