Fix page number and empty-result detection