Core/Misc: Fixed a bunch of issues found by static analysis
Core/Misc: Another batch of fixes for issues found by static analysis