Streams: many side-effect fixes:

- more straightforward whitelist-based detection
- special flat map handling