Fix pagination bugs and layout