Fix pagination bugs