refactored to streams

Tested samples by hand, most of work, not sure if notifications sample is working at all. Will file issue on notifications sample.