fixed various bugs in stream detection