Fixes calls to count when ranking a relation