Resource reference unsync fix

Please query the sizes of each keyset rather than copying the actual keys into a new collection - this will be much more efficient.