Added weak references support