fixed defects from coverity.com, Xcode static analyzer