Fix issue with weak references