Compilation and portability fixes
Fixed a bunch of stylistic and performance issues discovered via cppcheck.
Fixed a bunch of cppcheck warnings.
This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.