Bug fix for count all results and relation_n_n functionality