General refactoring (part 4 of lots)