Fix the way merging streams works and other minor bug fixes.