Misc optimizations.
Pass down total_value to algorithms in the command-line tool.
Misc fixes.
Merge pull request #1 from commonsmachinery/optimizations

Misc optimizations.