Removing some dead code, refactoring a bit
Fixing up some tests that were almost fully covered