This is humbling, but probably something most can relate to. I am currently adding functionality to a PHP application I wrote for a client 2 years ago. In the interest of full disclosure, this was the first "real" application I ever built from the ground up, in the sense that I actually met with clients to determine and write a spec. I then built the application by myself, learning SQL as I went (I had some prior rudimentary PHP experience).
The client contacted me this week to make modifications to existing functionality as well as add new modules to the application. I realize now that I did a poor job of modularizing the application from the start to make additions easier. Currently, the code base is almost 20,000 lines of code (it is a fairly sophisticated, if narrow application).
I'm struggling with whether or not to "rewrite" the application to make future changes easier and more efficient. I should point out that the nature of my agreement with the client is one in which I will be the only person making modifications in the future. They will not seek another developer for this app.
The budding programmer in me always wants to do things in the cleanest and most efficient way in order to satisfy my own OCD, but I do intend to bill the client for any time I spend rewriting. Morally, I feel fine with this because the initial rate that I charged them was low - they got a stable, working app which has been performing without any intervention from me for 2 years, and I got my first real development project on my resume. My dilemma is about when to decide to rewrite an application for the sake of future development.