refactoring of stream manager