A lot of refactoring, getting close to finished base template.