WIP: cursors refactoring, buckets merge procedure in progress