Correct the general stream compact to be more efficient.
Merge branch 'stream_compact_general'