Rework the flow framework to match the Java Flow framework more closely