Cherrypicked everything from pagination fix branch so we can merge this into dev-angular.
Merge pull request #1075 from opf/pagination-fix-5639

Cherrypicked everything from pagination fix branch so we can merge this ...