Add more tests.  Fix bugs.