This fixes all errors reported by cppcheck #3745.
Merge pull request #3746 from NAThompson/cppcheck_clean_3745

Cppcheck clean 3745