Added ref-counting to weak-ref.