Major code refactoring part 9.