Use weak reference in object factory to avoid cyclical references