Mehtad pagination fix

Also integrated Evan's changes into this pull request.