Pagination and several fixes

we have been using this branch vor a long time in production so I think I should commit back.