Within a few hours I rebuilt it from scratch.
That's when I realized the power of functional programming. There's no way I have been able to recover that quickly if I had used an imperative programming language.
Since that experience I've tried to follow a functional programming style whenever I can. I've realized that every variable is another state which adds to the complexity of the code.