Fix bug with paginate queries.