It's a difficult decision to make, the choice between improving an existing code base that has grown warts against the temptation of starting fresh and fixing what went wrong the first time, under the guise of learning from past mistakes.
I guess the lesson is: Don't try to rewrite your codebase from scratch unless you understand that you will spend an order of magnitude more time on the rewrite, even factoring in the experiences you have gained from doing it once.