Fixing subtle code errors based on results of the Xcode static analyzer.