Ref counting optimization.