A new implementation of cursor streaming

taken from the other branch