Some improvements

We applied some fixes found by automatic code analysis.