[z2099] Fix some problems detected by static code analysis

(based on commit [12143] - 45e0f8c)

(based on commit [s1718] - 7c37a7b)