pagination and several fixes