Cleaning up stream creation function