Add singleton streams, duplicate checks and some refactoring