Merge "Optimize the removal of garbage collected references to avoid memory leaks" into main