A little more cleanup; add more tests