fix errors found by static analysis