improve performance of merge stream

Closes #348.
Merge pull request #354 from satta/merge_faster

improve performance of merge stream