Fix gallery pagination and primary photo.