enable static code analysis, fix some problems
static code analysis fixes