Add helper reset internals function.

Use a little helper function to reset
the internal state of the flow when needed
instead of duplicating code that does this.

Change-Id: I51d83538a2920c7d387ffd1756e8d99413f4077e