Make the reference counter depend on the realm path

Perhaps a comment about why this is here.