Fixed warnings from Xcode Analyzer

I updated the code to fix problems found by the Xcode Analyzer