Added sanity checks to lifetime handling - now it seems to work ok after the final fix.