stream: a few cleanups and add guard for max timeout.