Moved cursor encoding and decoding to _paginate