Improved context handling when weakrefs go stale.