Fix problems detected by Clang's analyzer