Some of the code was nearly eight years old, virtually as old as the site itself, and was in need of good overhaul - yes it worked but had the appearance of being a hack (well it was a hack!) as basically as soon as I'd got it to work then I'd left it and moved on. Other blocks of the code had been changed over the years but the underlying faults had remained. In some instances a simple tweek or two was all that was needed but for many the changes are a complete reworking to bring the code up to standard. There's the advantage of a working version to refer to and to fall back on but equally having an existing solution can colour how you view the problem (and therefore the solution) so it's possible to end up with something that still has the existing faults without realising it.
An example would be the slideshow code. I'd rewritten it a couple of years ago to be more in line with modern thinking but there were still one or two subtle bugs in there that I hadn't managed to get to the bottom of and fix. I needed to add touch functionality for use on mobile devices so was modifying the code anyway so, rather than simply bolting on the new code, I went for the full rewrite.
By doing things like taking advantage of how browsers handle user actions such as mouse clicks I was able to simplify the workings of the code used to switch between slides which meant that the bugs disappeared! I also took the opportunity to add image caching so that when the user is looking at an image, that time is used to download the next image as a background task so it is immediately ready for viewing. Even with the extra code to deal with touch events and caching, the resulting code is cleaner and smaller by about 25% than what had gone before - I might even understand it when I come back to it in another eight years' time!
After all this techie stuff - it's time to get back to more active things!