a lot of progress after a few refactorings.