some rewrites on stream_t (still not functional)