Support multiple flows, add reset flow, refactoring