Generalize streaming functions
Added streaming demo