Added pagination for the restapi.
Removed old code from before api move.