[TASK] Cleanups according to code inspections

I finally had a chance to restore the code inspection rules and functionality in my editor - and it found quite a few issues in the code. This PR fixes the majority of those issues.