Fix for references counter behavior

References counter did not react when a reference was removed or adding a new reference
was canceled.

Change-Id: Ibd776629a1a5189315e7846059e7bf55acf93e93
Merge "Fix for references counter behavior"