minor refactoring of chunked_stream.js