Fixed coverity bugs