Cleaned up some code; fixed pagination to keep search query