It sounds like the all too common story of an inexperienced programmer being overwhelmed by technical debt[1] as their code grows larger and more complex. I'm sure it's a lesson that many programmers learn the hard way at some point in their careers (like I did).
[1] https://en.wikipedia.org/wiki/Technical_debt