Fix static analysis bugs