General refactoring. Part 2.