Fixed wrong pagination for categories, closes #684