Fixed few issues reproted by coverity.