Fixed a bunch of stylistic and performance issues discovered via cppcheck.
Adding initial import of optimization library
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.