Merge "Fix issue with freeing allocation with circular references."