Minor refactoring in stream API