Metrics, part 1.
More refactoring and cleaning.