Major code refactoring part 10.