stream: move utility functions

This way they can be used by the *Inline* functions as well.
stream: improve inline mode GAP handling

Don't conclude a GAP is 'final' until the missing data is ack'd.

Further, cleanup and unify more with the non-inline code.