Heavy refactoring into interfaces and classes.