Core/Misc: Fix issues reported by static analysis