bugfixes in paging code