More refactoring. More tests. Less code.