Unit Tests. Significant refactoring.