large code refactoring. This starts to look like it.