Fixed search bug, and added paginating calculations.