Recently I have been working on my scraping library webtoolkit.
To create it I had to extract code, simplify and streamline code.
After these operations my main project sources started working.
In summary: by simplifying code, cleaning API, you can fix problems. Unreadable code is prone to error.
It may be obvious, but too often we are lazy not to clean up APIs.