Fix mistakes in generating pagination buttons.