Performance, tests, and more

Mostly some performance improvements.  Also adding the framework for writing more tests.