Fix bugs in `next*- and `prev`- methods