Fix bugs on undefined stream