Refactor resetStream

I doesn't want to copy the code of resetStream to everywhere if I need
it. So I encapsulates the function of resetStream into reset.