Integrate optimizations & refactoring for 2013-khmer-counting paper

These are changes done in the course of working on the khmer-counting paper.  Many of them are obvious but a few could do with code review and/or cleanup.