Fix pagination page counting bugs