Fix AddReference and ReleaseReference methods.