Refactored 'stream update' code to be much more compact.