This is pretty similar to what happened to me. I was implementing an algorithm that had multiple parts and the data would arrive asynchronously.
The first time, I wrote the multipart algorithm using a functional style to encode each state. As the algorithm grew, it became more and more difficult to reason about and managing dependencies between the parts was harder, not easier.
When this became unwieldy, I rewrote it. However, when I wrote it the second time, I wrote the algorithm in a way that made it appear imperative. Everything was linear, starting with part B, then part C, etc. A small backend managed state, but you could read through the algorithm code and it almost seemed like it would run synchronously.
The second method was easier to read, debug, and modify. I will probably not go back to the functional method anytime soon.