If you're still encountering this issue then I suggest doing two things to gather additional information that might help us troubleshoot your issue:
1) Download Etresoft and upload a copy of the report so others can help determine if there are items on your system that need attention.
http://www.etresoft.com
2) Assuming you don't have any malware, and you have freed up sufficient space on your hard drive, then I suggest performing a more in depth review of your hard drive's SMART (Self-monitoring, Analysis, and Reporting Tool) logs using one of the tools that are available. Here are a couple of options that can be used in the demo mode to view the logs. See if they report any issues.
https://www.volitans-software.com/apps/smart-utility/
https://binaryfruit.com/drivedx
Have you checked for malware with a tool like Malwarebytes? You indicated that you removed a lot of unnecessary items? Were any of them apps or other files that were causing issues with your iMac? What types of files were they?
Have you tried creating a new user account to see if the issue persists? I realize you tried booting into Safe mode and ran Disk First Aid.
How to test an issue in another user account on your Mac - Apple Support
If you don't have a current backup of your data, now is the time to make one. I learned the hard way several years ago and now always have more than one backup of important files.