Filled out some base classes and added lots of tests. Some renaming, too.