fix some cppcheck warnings and -wextra