Various fixes from SCA and Coverity