Clean up commented-put code.
More code clean-up and minor optimizations.