Sounds like you and I are in similar situations. I work in finance and am somewhat of a "DevOps" type of person, although much less so than I used to be in my previous company. That being said, I wrote 2-3 monsters in the past few years - all were projects that I worked on solely from scratch - no outside involvement. The key for me personally was twofold:
1) Owning the project solely, in its entirety, from start to finish. this gives you that sense of responsibility that motivates you when you hit a road block or discover a major hurdle/roadblock/bug in your code
2) Creating large blocks of time to work on it. I found that when I tried to look at the code for 30-60 minutes at a time and get something done, that was the worst work I did and frequently had bugs or needed to be restructured entirely. The only way this didn't happen was when I was working frequently on the project. If I only had, for example, 5 hours in a given week to work on it, it was better to just not work on it unless those 5 hours could be sequential. It is hard to jump in to something, then think back to how it might affect something you wrote 2 weeks ago and then have to refer to that code. You'll spend more time just getting back up to speed than actually getting anything done.
For #1, this may or may not be possible for you. Not sure what the rules are about oversight and how well defined the roles are. But I found it extraordinarily helpful to involve absolutely no one. That also gave me a bird's eye view of everything and when you can recall how you structured a function/method/library that is being called, it's easy to see the pitfalls of how you will encounter a bug or hit your error capture section of your code. If you can't do #1 fully, then section off whatever you can. Clearly delineate what you are responsible for and what someone else is responsible for. For me, I hit limits with other systems that I needed to interact with within the company. So the maintainers of those systems were responsible for their system and only their system and I did my end separately.
For #2, this is usually very difficult to do. For the extremely large hurdles I needed absolute silence and huge blocks of time. This meant there were several weekends that I spent in the office, from 9 AM to 10 PM doing nothing but cranking out code with only food breaks. It worked for me, though. But it sucks big time for obvious reasons. Avoid that scenario at all costs if you can. Try to get those dedicated blocks at the office for complex coding tasks.
I would add a third critical element - that being to plan everything out in advance so that you can make sure what you have in mind actually works well. When you step through everything logically and see it all at once, you can identify problems, unforeseen situations, edge cases, and bottlenecks that will make you pull your hair out later on. Since this code already exists, I would instead modify this to be that you should plan out whatever solution you are going to pursue in full before you write even a line of code. Wait until you have a full game plan.